shell脚本 for循环、break跳出循环、continue结束本次循环
;案例1 # cat while.sh#!/bin/bash
while :
do
load=`w|head -1 |awk -F 'load average: ' '{print $2}'| cut -d . -f1`
if [ $load -gt 10 ]
then
top|mail -s "load is high:$load" admin@163.com
fi
sleep 30
done
;案例2
# cat while2.sh
#!/bin/bash
while :
do
read -p "Please input a number:" n
if [ -z "$n" ]
then
echo "You did not enter the number."
continue
fi
n1=`echo $n|sed 's///g'`
if [ ! -z "$n1" ]
then
echo "You can only enter a pure number."
continue
fi
break
done
echo $n
页:
[1]