break out of the loop
script
[root@lynn-04 shell]# vim break.sh
#!/bin/bash
for i in `seq 1 5`
do
echo $i
if [ $i -eq 3 ]
then
break
fi
echo $i
done
echo jiesu
Results of the
[root@lynn-04 shell]# sh break.sh
1
1
2
2
3
jiesu
continue to end this loop
, ignore the code under continue, and proceed directly to the next loop
script
[root@lynn-04 shell]# vim continue.sh
#!/bin/bash
for i in `seq 1 5`
do
if [ $i -eq 3 ]
then
continue
fi
echo $i
done
echo jiesu
Results of the
[root@lynn-04 shell]# sh continue.sh
1
2
4
5
jiesu
exit to exit the entire script
script
[root@lynn-04 shell]# vim exit.sh
#!/bin/bash
for i in `seq 1 5`
do
echo $i
if [ $i -eq 3 ]
then
exit
fi
echo $i
done
echo jiesu
Results of the
[root@lynn-04 shell]# sh exit.sh
1
1
2
2
3