码迷,mamicode.com
首页 > 系统相关 > 详细

Shell命令_case

时间:2016-11-11 14:40:17      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:ring   line   body   style   proc   table   ase   containe   href   

语法:

case "变量" in

    "变量1")

        ...

        ;; #输出两个分号

    "变量2")

        ...

      ;; #输出两个分号

    "变量3")

        ...

       ;; #输出两个分号

    *)

         ...

       ;; #输出两个分号

esac


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
 
# Author:James 2016-10-15
 
echo "want to output a,input 1:"
echo "want to output b,input 2:"
echo "want to output c,input 3:"
 
read -t 30 -p "please input your digit:" digit
 
case "$digit" in
        "1")
                echo "output a"
                #输出两个分号
                ;;
        "2")
                echo "output b"
                ;;
        "3")
                echo "output c"
                ;;
        *)
                #其它输入
                echo "output error,please input 1/2/2"
                ;;
esac






Shell命令_case

标签:ring   line   body   style   proc   table   ase   containe   href   

原文地址:http://www.cnblogs.com/gossip/p/6053973.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!