Allows you to choose between several patterns. First, check the value of the variable after the keyword case and compared with all the options in turn. Of course, must be the same as the standard to which you want to appeal. If the match is successful, the order is made or the command assigned to a given pattern. Otherwise, the default command used is marked with an asterisk: *) default_command. What is a good safeguard against mistakes made by our script. Case statement is ideally suited for the processing of arguments passed on the command line (of course combined with a while loop for example).
Attention
In many cases, case command can be replaced by the corresponding command if-elif-else ;) described in the section on the if command.
Syntax
case <variable> in
"Pattern1") command1;;
"Pattern2") command2;;
"Pattern3") command3;;
*) default_command
esac
Attention
It is important to place double semicolons after the block corresponding to the model, their absence will cause bad the script (most likely will not be reported to the warning!).
Example