The Case Statement

Case is a flow control construct that provides for multi-way branching based on patterns. Program flow is controlled on the bases of the word given

Case is a flow control construct that provides for multi-way branching based on patterns. Program flow is controlled on the bases of the word given. This word is compared with each pattern in order until a match is found, at which point the associated command (s) are executed. This syntax is:

case word in
pattern 1) command (s)
;;
pattern 2) command (s)
;;
pattern n) command (s)
;;
esac

When all the commands are executed control is passed to the first statement after the esac. Each list of commands must and with double semi-colon (;;).