back toc next

Multiple Conditions

case variable in
    pattern) command-list ;;
    pattern) command-list ;;
    ...
esac

Example:
case "$fruit" in
    "")   echo "\$fruit is empty"
        ;;
    lemon) echo The fruit is a lemon
        ;;
    orange) echo The fruit is a orange
        ;;
    *)  echo Unknown fruit
        ;;
esac

Case-constructs are often used for simple pattern matching.