case, switch, select — Shell Built-in Functions to Choose from a List of Actions

Synopsis

sh
case word in [pattern [| pattern]) actions;;] ... esac 
csh
switch (expression) 
 case comparison1: 
 actions 
 breaksw 
 case comparison2: 
 actions 
 breaksw 
... 
 default: 
endsw 
ksh
case word in [pattern [| pattern] ) actions;;] ... esac 
select identifier [in word...] ; do list; done 

Description

In shell scripts, you may want to take several different types of action depending on the value of a variable or a parameter. You can do so in the Bourne shell by using the case statement, in the C shell by using the case and switch statements, or in the Korn shell by using the case and select statements.

The value of the variable is successively compared against ...

Get Solaris™ 7 Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.