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

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

posted on 2014-05-18 22:33  温柔的机械猫  阅读(143)  评论(0编辑  收藏  举报

导航