- The syntax of the
until
command is:until test-commands; do consequent-commands; done
Execute consequent-commands as long astest-commands has an exit status which is not zero. The return status is the exit status of the last command executedinconsequent-commands, or zero if none was executed.
- The syntax of the
while
command is:while test-commands; do consequent-commands; done
Execute consequent-commands as long astest-commands has an exit status of zero. The return status is the exit status of the last command executedinconsequent-commands, or zero if none was executed.
- The syntax of the
for
command is:for name [ [in [words ...] ] ; ] do commands; done
Expand words, and executecommands once for each memberin the resultant list, with name bound to the current member. If ‘inwords’ is not present, the
for
commandexecutes thecommands once for each positional parameter that isset, as if ‘in "$@"’ had been specified. The return status is the exit status of the last command that executes. If there are no items in the expansion ofwords, no commands areexecuted, and the return status is zero.An alternate form of the
for
command is also supported:for (( expr1 ; expr2 ; expr3 )) ; do commands ; done
First, the arithmetic expressionexpr1 is evaluated accordingto the rules described below . The arithmetic expressionexpr2 is then evaluated repeatedlyuntil it evaluates to zero. Each timeexpr2 evaluates to a non-zero value, commands areexecuted and the arithmetic expressionexpr3 is evaluated. If any expression is omitted, it behaves as if it evaluates to 1. The return value is the exit status of the last command inlistthat is executed, or false if any of the expressions is invalid.
until
while
for