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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.