if <test> ; then [<statements including nested selection/repetiton constructs>] [elif <test> ; then [<statements including nested selection/repetiton constructs>]] [else [<statements including nested selection/repetiton constructs>]] fi- Note that elif and else constructs are optional.
- However the fi at the end is required
- The test uses the exit code to determine where to execute.
Quoting directly from the manual page:
case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac A case command first expands word, and tries to match it against each pattern in turn, using the same matching rules as for pathname expansion (see Pathname Expansion below). When a match is found, the corresponding list is executed. After the first match, no subsequent matches are attempted. The exit status is zero if no pattern matches. Otherwise, it is the exit status of the last com- mand executed in list.
while <test> ; do [<statements including nested selection/repetiton constructs>] done- Loops until test is false
- Does not have to execute at all if test is false 1st time around.
- :/true are commands that always return true.
- Uses exit code for test.
- Can have it's own I/O redirections