Shell continue循环

[oracle@june ~]$ cat continue.sh 
for i in  a b c d e f g
do
if  [ "$i" = "c" ]
then
echo xxxxxxxxxxxxxx
echo "跳过的字符为"$i
continue
fi
done
[oracle@june ~]$ sh -x ./continue.sh 
+ for i in a b c d e f g
+ '[' a = c ']'
+ for i in a b c d e f g
+ '[' b = c ']'
+ for i in a b c d e f g
+ '[' c = c ']'
+ echo xxxxxxxxxxxxxx
xxxxxxxxxxxxxx
+ echo $'314370271375265304327326267373316252c'
跳过的字符为c
+ continue
+ for i in a b c d e f g
+ '[' d = c ']'
+ for i in a b c d e f g
+ '[' e = c ']'
+ for i in a b c d e f g
+ '[' f = c ']'
+ for i in a b c d e f g
+ '[' g = c ']'


continue 跳过当前循环步,回到循环开始

原文地址:https://www.cnblogs.com/hzcya1995/p/13352312.html