| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Bash supports the following looping constructs.
Note that wherever a `;' appears in the description of a command's syntax, it may be replaced with one or more newlines.
until
until command is:
until test-commands; do consequent-commands; done |
while
while command is:
while test-commands; do consequent-commands; done |
Execute consequent-commands as long as test-commands has an exit status of zero. The return status is the exit status of the last command executed in consequent-commands, or zero if none was executed.
for
for command is:
for name [in words ...]; do commands; done |
for command
executes the commands once for each positional parameter that is
set, as if `in "$@"' had been specified
(see section 3.4.2 Special Parameters).
The return status is the exit status of the last command that executes.
If there are no items in the expansion of words, no commands are
executed, and the return status is zero.
An alternate form of the for command is also supported:
for (( expr1 ; expr2 ; expr3 )) ; do commands ; done |
The break and continue builtins (see section 4.1 Bourne Shell Builtins)
may be used to control loop execution.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |