linux-tutorial/codes/shell/示例脚本/逻辑控制/continue退出多层循环.sh

17 lines
250 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
#continuing an outer loop
for (( a=1; a<=5; a++))
do
echo "Iteration $a:"
for (( b=1; b<3; b++ ))
do
if [ $a -gt 2 ] && [ $a -lt 4 ]
then
continue 2
fi
var3=$[ $a * $b ]
echo " The result of $a * $b is $var3"
done
done