Shell Learning 15 days (while & until cycle) - 05day

(A) the while loop

The while loop is used by default to segment the carriage return, so the while loop for processing the text. After the required data on the use of the text line by line processing while, in fact, simply not suitable for loop processing text Ha!

while loop will not skip blank lines in the face, he would empty his as a variable. Therefore, while using the line when the need for variable length determination.

1. while the grammatical structure

Example one: while loop initialization batch creation of users and passwords

 

Example Two: while test whether a remote host is through

 

(Ii) an until loop

1. until grammatical structure:

Example one: until test whether through the remote host

Example 2: 1-100 accumulated value calculated by cyclic

let sum = $ sum + $ i and let sum + = $ i are equivalent

 

 

 

 

20200215

Published 15 original articles · won praise 0 · Views 3035

Guess you like

Origin blog.csdn.net/xx_ay/article/details/104335073