shell中的case语句

1、格式

case obj in

patten1)

command...

;;

patten2)

command...

;;

*)

command...

easc

2、示例

[root@localhost shell]# vi testcase.sh
#!/bin/bash
case $USER in
   root)
        echo "you are root,you are manager"
        ;;
   hadoop)
        echo "you are hadoop,you are user"
        ;;
   *)
        echo "you are guest"
esac
~
~
"testcase.sh" 11L, 160C written
[root@localhost shell]# chmod +x testcase.sh 
[root@localhost shell]# ./testcase.sh 
you are root,you are manager
[root@localhost shell]# 

你可能感兴趣的:(shell,shell,case,case菜单选择打印)