for, foreach, repeat — Shell Built-in Repeat Functions

Synopsis

sh
for word [in wordlist...] ; do actions; done 
csh
foreach word (wordlist) 
... 
end 

repeat count command
						
ksh
for word [in wordlist...] ; do actions; done 

Description

You can use loops in shell scripts to control the flow of execution in a script. A loop is an iterative mechanism that repeats a sequence of instructions until a predetermined condition is met. The for/foreach loop executes a list of commands one time for each value of a loop variable.

Bourne Shell

Each time a for command is executed, word is set to the next item taken from the in wordlist . If you omit in wordlist ..., then the for command executes the do actions once for each positional parameter that ...

Get Solaris™ 7 Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.