[英]About Switch Case in Bash Script
I'm newbie in bash script, I want to create a switch case without "break" like java code below 我是bash脚本的新手,我想创建一个没有“ break”的开关盒,如下面的Java代码
switch(choice) {
case 1:
System.out.println("1");
case 2:
System.out.println("2");
}
choice = 1 选择= 1
output: 1
2
so ... how can I do that in bash script :( 所以...我怎么能在bash脚本中做到这一点:(
Prior to bash
4, you couldn't; 在
bash
4之前,您不能; at most one block of commands in a case
statement would be executed. case
语句中最多执行一个命令块。 bash
4 introduced the ;&
case terminator, which causes fall-through. bash
4引入了;&
case终结符,这会导致失败。
case $choice in
1) echo 1 ;&
2) echo 2 ;;
esac
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.