Shell for Loop
The syntax for the Shell for loop is as follows
for inch List Do command1 command2 ... CommandN Done
Example:
for inch {1.. - } do echo $i Done
Class C language is also possible
for ((i=1; i<=; i + +)) do Echo $i Done
Shell while loop
while Command Do If True done
Example:
counter=0while5 ]do COUNTER='expr $ Counter+1' echo $COUNTER Done
Description: Returns True if counter is less than 5. Counter starting from 0, each time the loop is processed, counter plus 1, until count is 5 terminates.
Shell until loop
until Command Do Until true done
Example:
#!/bin/basha=0until [! $a-lt]do echo $a a= ' expr $a + 1 ' done
Note: When the "A is not less than 10" condition is false, the loop executes the command in the circulating body, that is, when a is greater than or equal to 10 o'clock, it will jump out of the loop body.
This script will output 0-9 numbers.
Linux Shell Learning Three