标签:continue only put ber .com numbers sed aac 技术
20.10 for循环seq 1 100
ls /etc/
20.11/20.12 while循环
语法 while 条件; do … ; done
案例1
#!/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" asldkfls@11.com
? ? fi
? ? sleep 30
done
#!/bin/bash
while :
do
read -p "Please input a number: " n
if [ -z "$n" ]
then
echo "you need input sth."
continue
fi
n1=echo $n|sed ‘s/[0-9]//g‘
if [ -n "$n1" ]
then
echo "you just only input numbers."
continue
fi
break
done
echo $n
20.13 break跳出循环
#!/bin/bash
for i in seq 1 5
do
? ? echo $i
? ? if [ $i == 3 ]
? ? then
? ?? ???break
? ? fi
? ? echo $i
done
echo aaaaaaa
20.14 continue结束本次循环
#!/bin/bash
for i in seq 1 5
do
? ? echo $i
? ? if [ $i == 3 ]
? ? then
? ?? ???continue
? ? fi
? ? echo $i
done
echo $i
20.15 exit退出整个脚本
#!/bin/bash
for i in seq 1 5
do
? ? echo $i
? ? if [ $i == 3 ]
? ? then
? ?? ???exit
? ? fi
? ? echo $i
done
echo aaaaaaa
20.10 for循环 20.11/20.12 while循环 20.13 break跳出循环 20
标签:continue only put ber .com numbers sed aac 技术
原文地址:http://blog.51cto.com/13227377/2159990