标签:for循环 command while done print com ++ gre class
if判断
1 if [ $a == $b ] 2 then 3 echo "等于" 4 else 5 echo "不等于" 6 fi
case分支选择
case $xs in 0) echo "0" ;; 1) echo "1" ;; *) echo "其他" ;; esac
while循环
1 # while true 等同 while : 2 # 读文件为整行读入 3 num=1 4 while [ $num -lt 10 ] 5 do 6 echo $num 7 ((num=$num+2)) 8 done 9 ########################### 10 grep a a.txt | while read a 11 do 12 echo $a 13 done 14 ########################### 15 while read a 16 do 17 echo $a 18 done < a.txt
for循环
1 # 读文件已空格分隔 2 w=`awk -F ":" ‘{print $1}‘ c` 3 for d in $w 4 do 5 $d 6 done 7 ########################### 8 for ((i=0;i<${#o[*]};i++)) 9 do 10 echo ${o[$i]} 11 done
until循环
1 # 当command不为0时循环 2 until command 3 do 4 body 5 done
流程控制
1 break N # 跳出几层循环 2 continue N # 跳出几层循环,循环次数不变 3 continue # 重新循环次数不变
标签:for循环 command while done print com ++ gre class
原文地址:https://www.cnblogs.com/alog9/p/11532645.html