tempad
ReadyGo!技术成就梦想 >>Shell教程 >> Linux程式设计-11.ShellScript(bash)--(7)流程控制select

Linux程式设计-11.ShellScript(bash)--(7)流程控制select

ReadyGo!技术成就梦想 网络搜索 efish 2008-2-24 2:50:10
selectnamedolist;done
select顾名思义就是在word中选择一项。与for相同,如果省略,将会使用Script後面所加的参数。

#!/bin/sh
WORD="abc"

selectiin$WORD;do
case$iin
a)
echo"IamA"
;;
b)
echo"IamB"
;;
c)
echo"IamC"
;;
*)
break;
;;
esac
done

执行结果
#./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
责任编辑: efish 参与评论 查找更多:
相关文章
Linux程式设计-11.ShellScript(bash)--(8)返回状态E… Linux程式设计-11.ShellScript(bash)--(8)返回状态Exit
Linux程式设计-11.ShellScript(bash)--(9)流程控制if Linux程式设计-11.ShellScript(bash)--(9)流程控制if
Linux程式设计-11.ShellScript(bash)--(10)控制圈wh… Linux程式设计-11.ShellScript(bash)--(10)控制圈while/until
Linux程式设计-11.ShellScript(bash)--(11)参数与变数 Linux程式设计-11.ShellScript(bash)--(11)参数与变数
Linux程式设计-11.ShellScript(bash)--(13)Bash内建… Linux程式设计-11.ShellScript(bash)--(13)Bash内建指令集
Linux程式设计-11.ShellScript(bash)--(12)函数func… Linux程式设计-11.ShellScript(bash)--(12)函数function
Linux程式设计-11.ShellScript(bash)--(14)Bash内建… Linux程式设计-11.ShellScript(bash)--(14)Bash内建参数
Linux程式设计-11.ShellScript(bash)--(15)提示符号 Linux程式设计-11.ShellScript(bash)--(15)提示符号
Linux程式设计-11.ShellScript(bash)--(16)算术表述 Linux程式设计-11.ShellScript(bash)--(16)算术表述
Linux程式设计-11.ShellScript(bash)--(17)重导Redi… Linux程式设计-11.ShellScript(bash)--(17)重导Redirection
2秒记住本站域名

玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的ReadyGo.com.cn

分类导航
ReadyGo!技术成就梦想