2016-05-12 16:37 by pursuer.chen, 64 阅读, 0 评论, 收藏, 编辑
简介
if循环
if conditon then commands
else
command fi
else这部分没有可以省略
或者
if condition then commands else if conditon then commands fi fi
可以在if中使用break退出循环
for循环
for (( i=0;i<=10;i++ )) { command
echo $i }
while循环
while ps -p `cat $PIDFILE` > /dev/null do let CNT+=1 if [ $CNT -gt 5 ] then break; fi sleep 1 done
until循环
until循环会一直执行循环直到条件为真就停止往下执行,所以下面的结构只会返回0-5
i=0; until [ $i -eq 6 ] do echo $i; let i++; done
总结
本文转自pursuer.chen(陈敏华)博客园博客,原文链接:http://www.cnblogs.com/chenmh/p/5486045.html,如需转载请自行联系原作者
