您的位置:首页 > 运维架构 > Shell

【转】shell学习笔记(七)——流程控制之while

2014-05-18 22:33 573 查看
while do done, until do done (不定回圈)

当 condition 条件成立时,就进行回圈,直到 condition 的条件不成立才停止

while [condition] -->中括号内的状态就是判断式

do -->回圈的开始

程序段落

done -->回圈的结束

例如:
#!/bin/bash
num=1
while [ $num -le 10 ]
do echo -e "\t the num is $num"
let num=num+1
done
运行输出:
the num is 1
the num is 2
the num is 3
the num is 4
the num is 5
the num is 6
the num is 7
the num is 8
the num is 9
the num is 10
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: