case $变量 in
"值1")
执行语句;
;;
"值2")
...
*)
默认执行语句
esac
#!/bin/bash read -p "请输入一个数:" num case $num in 1) echo "is 1" ;; 2) echo "is 2" ;; *) echo "is not 1 and 2" ;; esac