shell 变量自增
[clouder@server10-13 onecloud]$ cat test_push.sh
#!/bin/bash
#to test the connectity to gateway.push.apple.com 2195
#test 10 time if > 5 ,critical;if >1,warning
count=0
for i in `seq 1 10`
do
raw_result=`/home/clouder/paping -p 2195 -c 1 gateway.push.apple.com|grep 'Attempted'`
result=`echo $raw_result|awk -F '=' '{print $4}'|grep '100'`
rc=`echo $?`
if [[ $rc -eq 0 ]];then
echo '2195 not availibile'
count=$(($count+1))
fi
done
echo $count
用一个例子来演示会更加清晰