--break shell script it, continue

-break shell script it, continue

breakIt represents a cycle out of this layer, break nrepresented by the number of layers out of the loop. continueMeans skip the current cycle, continue nmeans skip ncycles.

example

#!/bin/bash
#文件名:test.sh
 
for i in 1 2 3 4 5 6 7 8 9
do
    if [ $i -eq 4 ];then
        continue
    else
        echo $i
    fi
 
    if [ $i -eq 6 ];then
        break
    fi
done

The output is:

ubuntu@ubuntu:~$ ./test.sh
1
2
3
5
6
ubuntu@ubuntu:~$
Published 84 original articles · won praise 29 · views 40000 +

Guess you like

Origin blog.csdn.net/qq_39852676/article/details/104741770