mbmc.net
当前位置:首页 >> shEll whilE BrEAk >>

shEll whilE BrEAk

bash shell script (bash脚本)中,break是退出一层循环,break 2是退出2层循环(当有相互嵌套时),.... break: break [n] Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exi...

bash shell script (bash脚本)中,break是退出一层循环,break 2是退出2层循环(当有相互嵌套时),....break: break [n] Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exit...

do语句要提前一行。 while循环用于不断执行一系列命令,也用于从输入文件中读取数据;命令通常为测试条件。其格式为:while command do Statement(s) to be executed if command is true done 命令执行完毕,控制返回循环顶部,从头开始直至测试...

break 命令导致跳出当次循环 比方说下面这段代码打印从 0 到 20 的数字 遇到 3 和 11 跳出循环不打印往后执行: 运行效果: exit 命令中止全部代码的运行 比方说把上面代码里面的 continue 改成 exit 运行效果: 运行到 3 就结束全部代码了

exit是在被调用的脚本里面,肯定会退出被调用的脚本了。如果不想继续执行while循环后面的程序可以在do后面的条件上加上break

bash shell script (bash脚本)中,break是退出一层循环,break 2是退出2层循环(当有相互嵌套时),.... break: break [n] Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exi...

bash shell script (bash脚本)中,break是退出一层循环,break 2是退出2层循环(当有相互嵌套时),.... break: break [n] Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exi...

break 语句可以结束while,for,until或select等结构的执行,即从结构中跳出,并往后继续执行。 exit 直接退出整个脚本,后面的代码不再执行。

先单独看break的例子: #!/bin/bash count=0 while [ $count -lt 5 ] do if [ ! -s /root/test.sh ];then echo "test.sh doesn't exist!" else echo "test.sh exist!" break fi sleep 3 if [ ! -s /root/kevin.sh ];then echo "kevin.sh doesn't...

bash shell script (bash脚本)中,break是退出一层循环,break 2是退出2层循环(当有相互嵌套时),.... break: break [n] Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exi...

网站首页 | 网站地图
All rights reserved Powered by www.mbmc.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com