Integer comparison
-eq: Equals
-NQ: Unequal
-GT: Greater Than
-LT: Less than
-ge: greater than or equal to
-le: Less than or equal to
Usage:
A=3
B=4
[$A-eq $B]
echo $?
Logic and:&&
Logical OR: | |
Variable name:
1. Can only contain letters, numbers, underscores, and cannot begin with a number
2. Should not be the same as the existing environment variables in the system
3. It is best to see the name and the meaning
Single Branch if statement
If judgment condition: Then
Statement1
Statement2
..
Fi
If statements for dual branches
if judgment condition; then
Statement1
Statement2
..
Else
Statement3
Statement4
..
Fi
How to perform arithmetic operations in the shell:
A=3
B=6
1. Let arithmetic op-expression
c= $A + $B
2. $[arithmetic operation expression]
c=$[$A + $B]
3.$ ((arithmetic expression))
c=$ (($A + $B))
4.expr arithmetic expression, in which the various operands and operations in the expression are to be inverted, and to use the command reference
c= ' expr $A + $B '
Linux Learning Record-number comparison-IF statement-arithmetic operations