If Else judgment statement
If statement
Syntax Format 1:
if condition then statement 1 Statement 2 ... Statement NFI
Syntax Format 2:
Often used in terminal command prompt
if [conditional];then statement; fi
If Else statement
Syntax format:
if condition then statement 1 Statement 2 ... Statement nelse statement fi
If else-if Else statement
Syntax format:
if condition 1then Statement 1elif condition 2then Statement 2 Else Statement NFI
For Loop statement
Syntax Format 1:
for inch value 1 Value 2 ... Value n do statement 1 Statement 2 ... Statement Ndone
Syntax Format 2:
Often used in terminal command prompt
for in value 1 value 2 ... Value n; do statement 1; statement 2 ... done;
For Dead Loop
Syntax format:
for ((;;))
While Loop statement
Used to continuously execute a series of commands.
Syntax format:
while conditions Do Statement Done
While Dead loop
Syntax Format 1:
while : Do Statement Done
Syntax Format 2:
while true Do Statement Done
Until cycle
Similar to the while loop, except that while the value is true to continue execution, until is the value of false continuation.
Syntax format:
until conditions Do Statement Done
Case Selection Statement
The case value must be followed by in, and each pattern must end with a closing parenthesis. After a match discovery value conforms to a pattern, all commands begin to execute until they are encountered;; End.
If there is no matching pattern, use an asterisk * to capture the value and then execute the subsequent command.
Syntax format:
Case inch mode 1) Statement 1 ... statement n;; mode 2) Statement 1 ... Statement N;;esac
The syntax of a case requires a ESAC (which is case in turn) as the closing tag, with a closing parenthesis for each case branch, and a break with two semicolons
Break command
The break command is to jump out of all loops and terminate all subsequent loops
Continue command
The continue command jumps out of the current loop, but does not jump out of all loops, just jumps out of the current loop, and executes the next loop
Shell Programming-Statements (vii)