1.while语句
while 条件
do
语句1
语句2
done
while语句只有条件为真时才会向下执行命令,条件为假时不向下执行任何命令
2.while语句示例
<1>条件为真时
#!/bin/bash
while true
do
read -p "please input number: " NUM
echo $NUM
done


<2>条件为假时
#!/bin/bash
while flase
do
read -p "please input number: " NUM
echo $NUM
done


3.until语句
until 条件
do
语句1
语句2
done
until语句与while语句相反
until语句只有条件为假时才会向下执行命令,条件为真时不向下执行任何命令
4.until语句示例
<1>条件为假时
#!/bin/bash
until flase
do
read -p "please input number: " NUM
echo $NUM
done


<2>条件为真时
#!/bin/bash
until flase
do
read -p "please input number: " NUM
echo $NUM
done


1039

被折叠的 条评论
为什么被折叠?



