First page Back Continue Last page Graphics

Control: The IF Statement (Quigley pages 886 – 896)

The command is executed and its result (the same as $?) evaluated. If the result is zero, the then clause is executed; if it's not zero, it's skipped. This evaluation is then repeated in turn for each elif clause, if any.

If no then clause is executed, the statements in the optional else clause is executed.

if command

then

statements

elif command

then

statements

else

statements

fi