Continue and break are commonly used in the while, until, select Loop statements, exit this round or all loops under specified conditions, we need to use the example to verify the results of the operation, it is good to understand. But it's really not a good idea to read the text.
Continue usage
Continue used in the loop body
Continue [n]: End of the nth layer of the current cycle, and directly into the next round of judgment; the inner layer is the 1th floor.
While CONDTIITON1; Do
CMD1
...
if CONDITION2; Then
Continue
Fi
Cmdn
...
Done
Example Demo:
#!/bin/bash
#Author: Wangjun
#Contact qq:183530300
#Version: 1.0
#Create time:2016-08-20 12:23:58
#Description: Break and Continue Test
Declare-i i=0
while [[$I-lt 5]];d o
Let i++
if [[$I-eq 3]];then
Continue
#break
Fi
Echo $I
Done
650) this.width=650; "title=" Break.png "src=" http://s2.51cto.com/wyfs02/M00/86/37/ Wkiom1e4bjsqbyyraaar-7abrew205.png "alt=" Wkiom1e4bjsqbyyraaar-7abrew205.png "/>
Break usage
Break is used in the loop body
Break [n]: Early end of the nth layer cycle, the inner layer is the 1th layer
While CONDTIITON1; Do
CMD1
...
if CONDITION2; Then
Break
Fi
Cmdn
...
Done
Example Demo:
#!/bin/bash
#Author: Wangjun
#Contact qq:183530300
#Version: 1.0
#Create time:2016-08-20 12:23:58
#Description: Break and Continue Test
Declare-i i=0
while [[$I-lt 5]];d o
Let i++
if [[$I-eq 3]];then
#continue
Break
Fi
Echo $I
Done
650) this.width=650; "title=" Continue.png "src=" http://s5.51cto.com/wyfs02/M02/86/37/ Wkiol1e4bdpro2vgaaapzbstybu916.png "alt=" Wkiol1e4bdpro2vgaaapzbstybu916.png "/>
This article is from the "Love Firewall" blog, be sure to keep this source http://183530300.blog.51cto.com/894387/1840695
Shell script Loop statement--continue and break