echo -n "Enter the name of an animal: " read ANIMAL echo -n "The $ANIMAL has " case $ANIMAL in horse | dog | cat) echo -n "four";; man | kangaroo ) echo -n "two";; *) echo -n "an unknown number of";; esac echo " legs."
This case command tests the value of the variable ``ANIMAL''. Each clause starts with one or more patterns terminated by a ``)''. This is followed by one or more commands, that note the double pair of ``;'' that ends a clause. The pattern ``*'' is a catch-all. case is terminated by esac.