Bash
Conditional and Looping Statements
if
if test-commands; then
consequent-commands;
[elif more-test-commands; then
more-consequents;]
[else alternate-consequents;]
fi
case
case word in
[ [(] pattern [| pattern]...) command-list ;;]...
esac
casewill selectively execute thecommand-listcorresponding to the firstpatternthat matchesword.
select
select name [in words ...]; do commands; done
- Expand the list of words follwiong
in, generating a list of items to stderr preceeded by a number. A line is read from stdin, and the corresponding
until
until test-commands; do consequent-commands; done
while
while test-commands; do consequent-commands; done
for
for name [ [in words ...] ; ] do commands; done
- expand
wordsand then executecommandsonce for each - if
in wordsis not specified, the for command executes once forr each positional parameter.
for (( expr1 ; expr2 ; expr3 )) [;] do commands ; done