The break command can contain one parameter. A break loop without a parameter can only exit the innermost loop, while breakN can exit the N-layer loop. The continue command can also contain a parameter. A continue command without a parameter only removes the remaining code of this loop, while continueN removes all the remaining code of the N-tier loop, but the number of cycles remains unchanged. #! /Bin/shforiin & quot; abcd & quot; do &
The break command can contain one parameter. A break loop without a parameter can only exit the innermost loop, while break N can exit the N-layer loop.
The continue command can also contain a parameter. A continue command without a parameter only removes the remaining code of this loop, while continue N removes all the remaining code of the N-tier loop, but the number of cycles remains unchanged.
#!/bin/sh
for i in"a b c d"
do
echo "$i "
for j in `seq 10`
do
if [ $j -eq 5 ];then
break
fi
echo "$j "
done
echo
done
Break result:
A 1 2 3 4
B 1 2 3 4
C 1 2 3 4
D 1 2 3 4
Result of break 2:
A 1 2 3 4
Continue result:
A 1 2 3 4 6 7 8 9 10
B 1 2 3 4 6 7 8 9 10
C 1 2 3 4 6 7 8 9 10
D 1 2 3 4 6 7 8 9 10
Result of continue 2:
A 1 2 3 4
B 1 2 3 4
C 1 2 3 4
D 1 2 3 4