1, for: Read different variable values, execute the same set of commands one by one, until the value is complete exit, variable values are separated by a space
Syntax: For variable value in value list
Do
Command
Done
2, while: Repeated testing a condition, the establishment is executed, into the next loop, until the condition is not established
Syntax: While [condition Test]
Do
Command
To add a change test condition statement
Done
To add a user in bulk:
I=qs
While [$i-le $JS]
Do
Useradd $BM $i
echo "123456" ipasswd--stdin $BMSi
Let i++
Done
While condition is true: Represents always true, dead loop, must use Exit or Break command to end loop
Must be incremented to avoid a dead loop: Method:
i= ' Expr i + 1 '
Let I=i+1
Let i++
3. Case: Perform different command sequences for different values of variables
Syntax: Case variable value in
Mode 1)
Command sequence 1
;;
Mode 2)
Command Sequence 2
;;
......
*)
Default command sequence
Esac
value, brackets [], whichever is selected
Horizontal Bar-, representing the range of values
Vertical Bars |, representing or
Shell script app (for, while, Case statement application)