while循环
基本语法:
while <条件>
do
<命令>
done
while循环更多地用于读取标准输入的内容来实现循环
例1:依次打印数字
#!/bin/bash #while test #by sunny i=10 while ((i<100)); do sleep 1 echo "the num is $i" ((i++)) if [ $i -gt 15 ];then # i超过15会停止循环跳出 break fi done 执行 sh while1.sh the num is 10 the num is 11 the num is 12 the num is 13 the num is 14 the num is 15