Loops in any programming language are more than enough, and of course the shell script also has a looping statement, including a for statement, while statement. This article mainly uses the actual use case to illustrate what common use methods and techniques are used for the while.
one, for loop use
1. SEQ Command mode
for in $ (seq); do Echo " $i " Done
2. C Language Grammar method
for ((i=0; i<9; i++)); do Echo " $i " Done
3. Looping through a list of files
for file in $ (lsdoes echo"$file" Done
4. Looping through array elements
for inch do Echo " $i " Done
5. Looping through the script parameter list
for inch do Echo " $arg " Done
6. Explicitly specifying a list
for inch 1 2 3 ; do Echo $i Done
7. List for loop
for inch {1.. 5 do Echo " $i " Done
8. Step-Count jumping mode for loop
for inch {1.. . 2}; do Echo " $i " Done
second, while loop use
1. Common while syntax
while ((i<= )); Do ... ... Done
while " $num " 4 Do ... ... Done
while " $num " 0 Do ...... Done
Pending update ...
Shell script loop using for while explanation