Repeated-Action Commands
The Bourne shell provides three repeated-action commands, each of which corresponds to constructs you might have seen before in other programming languages:
for
while
until
These commands cause a program to loop or repeat. They are described next.
The for Loop
A useful shell command is the for loop, which is the simplest way to set up repetition in a shell script. The syntax of a for loop is as follows:
for name [ in wordlist . . . ] do list done
Each time a for command is executed, name is set to the next word taken from the in word list. If in word . . . is omitted, the for command executes the do list once for each positional parameter that is set. Execution ends when no more words are in the list. The ...
Get Inside Solaris™ 9 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.