if ... ;then
fi
if ...;then
else
...
fi
if ...; then
elif ...; then
else
...
fi
case ... in
pat1)
...
;;
pat2)
...
;;
*)
...
;;
esac
~]# for i in `ls /etc` ;do echo $i; done
~]# sum=0; for i in {1..100};do let sum=$sum+$i; done;echo $sum
for i in {1..9};do
for j in `seq $i`;do
echo -e "${j}x${i}=$[j*i]\t\c"
done
echo
done
for i in {1..9};do
for j in `seq $i`;do
printf "%sx%s=%s\t" ${j} ${i} $[j*i]
done
echo
done
for ((sum=0,i=1;i<=100;i++));do
let sum+=$i
done
echo sum=$sum
~]# while [ $n -le 10 ];do echo $n; let n++; done
~]# n=0;while (($n<5));do echo $n; let n++; done
~]# df | sed -rn '/^\/dev\/sd/s@^([^ ]+) .* ([0-9]+)% .*@\1 \2@p'|while read DEV PER;do if [ $PER -ge 20 ];then mail -s "warning" root; fi; done
for ((i=0;i<=10;i++));do标签:do,第八天,sum,echo,回炉,continue,done,...,linux From: https://blog.51cto.com/dayu/5972704
for ((j=1;j<=10;j++));do
[ $j -eq 5 ] && continue
echo $j
done
echo "---------"
done
for ((i=0;i<=10;i++));do
for ((j=1;j<=10;j++));do
[ $j -eq 5 ] && continue 2 #continue 2的意思是退出当次两层循环
echo $j
done
echo "---------"
done