linux-tutorial/codes/shell/示例脚本/逻辑控制/使用break跳出外部循环.sh
2019-10-10 08:56:31 +08:00

18 lines
252 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# break n默认为1
for (( a = 1; a <= 3; a ++ ))
do
echo "Outer loop : $a"
for (( b = 1; b < 100; b ++ ))
do
if [ $b -gt 4 ]
then
break 2
fi
echo " Inner loop:$b"
done
done