if 判断语句
if [ $a == $b ]
then
echo "等于"
else
echo "不等于"
fi
case分支选择
case $xs in
) echo "" ;;
) echo "" ;;
*) echo "其他" ;;
esac
while循环
# while true 等同 while :
# 读文件为整行读入
num=
while [ $num -lt ]
do
echo $num
((num=$num+))
done
###########################
grep a a.txt | while read a
do
echo $a
done
###########################
while read a
do
echo $a
done < a.txt
for 循环
# 读文件已空格分隔
w=`awk -F ":" '{print $1}' c`
for d in $w
do
$d
done
###########################
for ((i=;i<${#o[*]};i++))
do
echo ${o[$i]}
done
until 循环
# 当command不为0时循环
until command
do
body
done
流程控制
break N # 跳出几层循环
continue N # 跳出几层循环,循环次数不变
continue # 重新循环次数不变