next up previous
Next: The ifthenelse Structure Up: Looping and Making Choices Previous: The for Loop

The while And until Loops

The general form of the while loop is this:
while control-command
do
commands
done

Each cycle of the while loop, the shell attempts to execute the control command. If it returns a zero exit status (success), the commands between do and done are executed. This process continues until the control command yields a nonzero exit status (failure).

The general form of the until loop is this:
until control-command
do
commands
done

Each cycle of the until loop, the shell attempts to execute the control command. If it returns a nonzero exit status (failure), the commands between do and done are executed. This process continues until the control command yields a zero exit status (success).



Roger Hampel
Mon Feb 2 09:39:25 MET 1998