back toc next

Conditions

complex condition

if test-commands
then
    consequent-commands
elif more-test-commands
then
    more-consequents
else alternate-consequents
fi

Example:
if test -z "$fruit"; then
    echo "\$fruit is empty"
elif test $fruit = "lemon" ; then
    echo "Lemon"
elif test $a = "orange"; then
    echo "Orange"
...
else
    echo "Unknown Fruit"
fi