Control Commands
case value in
pattern1) | commands1;; |
pattern2) | commands2;; |
. . . | |
patternn) | commandsn;; |
esac
Execute commands associated with the pattern that matches value.
for variable in word1 word2. . . wordn
do
commands
done
Execute commands once for each word, setting variable to successive words each time.
for variable
do
commands
done
Execute commands once for each positional parameter, setting variable to successive positional parameters each time.
if command1
then
commands
fi
Execute commands if command1 returns a zero exit status.
if command1
then
commands2
else
commands3
fi
Execute commands2 if commands1 returns a zero exit status, otherwise execute commands3.
if command1
then
commands
elif command2
then
commands
. . .
elif commandn
then ...
Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The 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.