linux-tutorial/codes/shell/示例脚本/逻辑控制/continue退出多层循环.sh
2019-10-10 08:56:31 +08:00

18 lines
312 B
Bash

#!/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