case (in) / esac
The case construct is the shell scripting analog to switch in C/C++. It permits branching to one of a
number of code blocks, depending on condition tests. It serves as a kind of shorthand for multiple
if/then/else statements and is an appropriate tool for creating menus.
case "$variable" in
"$condition1" )
command...
;;
"$condition2" )
command...
;;
esac
:空操作
The case construct is the shell scripting analog to switch in C/C++. It permits branching to one of a
number of code blocks, depending on condition tests. It serves as a kind of shorthand for multiple
if/then/else statements and is an appropriate tool for creating menus.
case "$variable" in
"$condition1" )
command...
;;
"$condition2" )
command...
;;
esac
:空操作