Shell流程控制之while

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/asty9000/article/details/86670807

基本语法

while condition
do
    dosomething...
done

只要condition为true就会执行dosomething,直到condition为false为止。condition通常为test表达式。

无限循环的写法如下:

while true
do
    dosomething...
done

while :
do
    dosomething...
done

简单示例

num=1
while (( $num<=5))
do
    echo $num
    let "num++"
done

猜你喜欢

转载自blog.csdn.net/asty9000/article/details/86670807