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


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

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


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.