shellScript之select语句

来源:互联网 发布:java生成随机数的方法 编辑:程序博客网 时间:2024/05/18 19:45
#!/bin/bashecho "what you favorite color?"select color in "red" "blue" "green" "white" "black"do  breakdoneecho "you have selectd $color"

结果:

~/Note/test # ./23select.sh what you favorite color?1) red2) blue3) green4) white5) black#? 4you have selectd white

例子2:利用命令行传递参数

#!/bin/bashecho "what you favorite color?"select colordo  breakdoneecho "you have selectd $color"
结果:

~/Note/test # ./24select.sh red blue green white blackwhat you favorite color?1) red2) blue3) green4) white5) black#? 5you have selectd black


原创粉丝点击