1, test: the detection of the expression is established, the return value is 0, otherwise, not 0
Method:
1) test expression
2) "Expression"
2. File test:
-D: Whether it is a directory
-F: Whether it is a file
-E: whether there is
-r: Whether Read permission is available
-W: Write permission
-X: Whether there are execute permissions
3, Integer value comparison:
-eq: Equals
-ne: Not equal to
-GT: Greater Than
-LT: Less than
-ge: greater than or equal to
-le: Less than or equal to
4. String comparison:
=: string content is the same
! =: string content is not the same
-Z: string content is empty
5. Logic Test:
-A or &&: Also, two conditions are true at the same time, the preceding command executes successfully before executing the subsequent command
-O or | | : Or, a condition is true
! : No, true if condition is not satisfied
6, if statement: Conditional Judgment Statement, the establishment is executed, otherwise launched or the next judgment, up to execute a command
1) Single branch: Judge once, set up execution, do not set out
If "Conditional expression"
Then
Command
Fi
2) Double branch: Judge once, set up execute an order, do not set to execute another command
If "Conditional expression"
Then
Command 1
Else
Command 2
Fi
3) Multi-branch: Judge multiple times, execute sequentially
If "Conditional expression"
Then
Command 1
Elif "Conditional expression"
Then
Command 2
Else "conditional expression"
Then
Command 3
Fi
Shell Script application (if statement's structure)