bash中选择结构、循环结构与break、continue

if两种选择结构


if 测试条件; then
	程序块
else
	程序块
fi
if 测试条件1; then
  程序块
elif 测试条件2; then
	程序块
...
elif 程序条件n; then
	程序块
else
  程序块
fi

case选择结构


case 变量 in
Pattern1)
	程序块
	;;
Pattern2)
	程序块
	;;
...
Patternn)
	程序块
	;;
*)
	程序块
	;;
esca

for循环结构


for 变量 in 列表; do
	程序块
done

while循环结构


while 测试条件; do
	程序块
done

until循环结构


until 测试条件; do
	程序块
done

break与continue


break [n]终止从内向外数第n层循环,默认本层循环,感觉查done数目就好
continue [n]结束当前从内向外数第n层循环,继续下次循环,默认本次循环

原文地址:https://www.cnblogs.com/hesper/p/8902220.html