计算机网络/计算机科学与应用/系统/运维/开发

十、case条件语句

1、case条件语句

case "变量" in

值1)

指令1...

;;

值2)

指令2...

;;

*)

指令3...

esac

[root@localhost shell]# cat 9.sh 
#!/bin/bash
read -p "Please input a number:" ans
case "$ans" in
1)
echo "The num you input is 1"
;;
2)
echo "The num you input is 2"
;;
*)
echo "Please input 0-9 int"
esac



只要认真对待生活,终有一天,你的每一份努力,都将绚烂成花。

评论

^