Linux程式设计-11.ShellScript(bash)--(7)流程控制select
selectname[inword;]dolist;done
select顾名思义就是在word中选择一项。与for相同,如果[inword;]省略,将会使用Script後面所加的参数。 例 #!/bin/sh WORD="abc" selectiin$WORD;do case$iin a) echo"IamA" ;; b) echo"IamB" ;; c) echo"IamC" ;; *) break; ;; esac done 执行结果 [foxman@foxmanbash]#./select_demo 1)a 2)b 3)c #?1 IamA 1)a 2)b 3)c #?2 IamB 1)a 2)b 3)c #?3 IamC 1)a 2)b 3)c #?4 上一篇:Linux程式设计-11.ShellScript(bash)--(6)流程控制case 下一篇:Linux程式设计-11.ShellScript(bash)--(8)返回状态Exit 更多相关文章
|
推荐文章
精彩文章
|