举个简单的例子
</pre><pre code_snippet_id="1864684" snippet_file_name="blog_20160903_3_1916082" name="code" class="plain"> 1 #!/bin/bash
2
3 #author
4
5
6
7 echo 'input "1" '
8
9 echo 'input "2" '
10
11 echo 'input "3" '
12
13 read -p "input your choice " -t 30 tmp
14
15 case $tmp in
16 "1")
17 echo "go 1";;
18 "2")
19 echo "go 2";;
20 "3")
21 echo "go 3";;
22 "*")
23 echo "no choice";;
24 esac
注意: 分句后面要有;;
变量 $tmp 没有双引号,的话,下面值要有