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

相关文章:

  • 2022-02-01
  • 2022-01-05
  • 2022-12-23
  • 2021-04-11
  • 2022-02-06
  • 2021-04-04
  • 2021-04-19
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2021-08-23
  • 2021-05-16
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案