标签:command
在shell 脚本中,除了用if来判断逻辑外,还有一种常用的方式,那就是case了。具体格式为:
case 变量in
value1)
command
;;
value2)
command
;;
value3)
command
;;
*)
command
;;
esac
举例:
[root@bogon ~]# cat case.sh
#/bin/bash
read -p "input a number:" n
a=$[$n%2]
case $a in
1)
echo "the unm is odd"
;;
0)
echo "the unm is even"
;;
*)
echo "it is not a num"
;;
esac
标签:command
原文地址:http://9872158.blog.51cto.com/9862158/1889295