In previous studies, we learned that the while loop shape is:
while expression;
Statement
...
Done
This grammatical structure loops as long as the expression meets the criteria to execute the statement in the loop body, or the loop is rolled out.
Two special while loops are described next
While loop attribute syntax one
While:;d o
Loop body
Done
This loop does not have expression, that is, there is no control condition, so the while using this notation, will be infinite loop down.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D8/wKioL1PH3JjQwrxLAAFi_0dTDtA685.jpg "title=" w1.png "alt=" Wkiol1ph3jjqwrxlaafi_0dtdta685.jpg "/>
In order to solve the Infinite loop (dead loop) and the control loop process, we can use the continue and break keywords to control.
Continue: Indicates that the statement following the continue in the current loop is not executed, goes directly to the next cycle, and does not exit the loop.
Break: Exits the loop directly.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/D9/wKioL1PH4zaDuOdeAADwEOxXUmk255.jpg "title=" Con1.png "alt=" Wkiol1ph4zaduodeaadweoxxumk255.jpg "/>
While loop special syntax two
While Read Line;do
Statement
...
Done </path/to/somefile
This loop indicates that each row of a file is read sequentially and the contents of each row are assigned to the variable line.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D8/wKioL1PH3uvwC9mCAADMRy9b6AU356.jpg "title=" w2.png "alt=" Wkiol1ph3uvwc9mcaadmry9b6au356.jpg "/>
This article from the "Linux Learning Path" blog, declined reprint!