[prev] [index] [next]

Case command

case provides multi-way choice based on patterns:

case word in
pattern1)  commandList1 ;;
pattern2-2)  commandList2-2 ;;
...
patternn)  commandListn ;;
esac

The word is compared to each patterni in turn.

For the first matching pattern, corresponding commandListi is executed and the statement finishes.

Patterns are those used in filename expansion   ( * ? [] ).