shell编程 case语句
生活随笔
收集整理的这篇文章主要介绍了
shell编程 case语句
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
case语句格式
case 语句如果某个选项没有任何语句,也要加;;否则会出下边错误
test: line 166: syntax error near 《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读
| # vi test.sh : echo "input : " read num echo "the input data is $num" case $num in 1) echo"January";; 双分号结束 2) echo "Feburary";; 5) echo"may" 每个case可以有多条命令 echo "sdfd" echo"sdf";; 但最后一条命令一定是双分号结束 *) echo "not correct input";; *)是其他值、default的意思 esac |
| # sh ./test.sh input : 2 the input data is 2 Feburary # sh ./test.sh input : ter the input data is ter not correctinput |
case 语句如果某个选项没有任何语句,也要加;;否则会出下边错误
test: line 166: syntax error near 《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读
总结
以上是生活随笔为你收集整理的shell编程 case语句的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: shell 循环判断语法
- 下一篇: 各种排序算法的讲解与代码实现