shell中断,继续与退出shell
用法1、break退出整个循环bash
[root@localhost test]# cat 10.shide
#!/bin/bashit
for i in `seq 1 10`class
dotest
echo $i循环
if [ $i -eq 4 ]di
thenview
breakvi
fi
echo $i
done
echo "for done"
用法2、continue退出本次循环
[root@localhost test]# cat 10.sh
#!/bin/bash
for i in `seq 1 10`
do
echo $i
if [ $i -eq 4 ]
then
continue
fi
echo $i
done
echo "for done"
用法3、结束shell
[root@localhost test]# cat 10.sh
#!/bin/bash
for i in `seq 1 10`
do
echo $i
if [ $i -eq 4 ]
then
exit
fi
echo $i
done
echo "for done"