shell/结构化命令/使用break跳出外部循环.sh

17 lines
199 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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