Linux control statements need to use a variety of conditions, and the conditions are divided into different types.
To test an expression:
(1) Integer test
A-GT B: Greater Than
A-ge B: Greater than or equal to
A-eq B: Equals
A-le B: Less than or equal to
A-ne B: Not equal to
A-lt B: Less than
Example: 650) this.width=650; "src=" Http://images0.cnblogs.com/blog2015/764880/201506/021729231336104.x-png "/>
(2) String test
A > B
A<b
A<=b
A>=b
A! =b: Not equal to
A==b or A =b: equals
-Z A: Determine whether a is empty, empty is true, not empty for false
-N A: Determine whether a is empty, not empty is true, empty is false
(3) file test
-e $file: exists, exists as true
-A $file: ditto, deprecated
-F $file: Whether the file exists and is a normal file;
-D $file: Exists and is a directory
-H $file: exists and is a symbolic link file
-L $file: Ibid.
-B $file: exists and is a block device file
-C $file: exists and is a character device file
-S $file: Socket file
-P $file: Pipe file
-R $file: Whether the current user has read access to this file
-W $file: Write permission
-X $file: Execute Permissions
-U $file: Whether the file has suid permissions
-G $file: Whether the file has Sgid permissions
-K $file: Whether the file has sticky permissions
-O $file: Whether the current user is the owner of the file
-G $file: Whether the current user belongs to a group belonging to a file
-N $file: Whether the file has been modified since it was last read
[-n/tmp/fstab]
echo $?
$f 1-nt $f 2: Is file F1 newer than file F2
$f 1-ot $f 2: File F1 is older than file F2
$f 1-ef $f 2: Two files is a hard link to the same file
Combination test conditions
Add a logical operator to a condition Note: commands cannot be used with these
Or,-O:
With:-a:[$uid-gt 0-a $uid-lt 500]
Non -:!
-Z: Empty
Command connection: Short-circuit operator, string command to use this type of command
and &&
Or: | |
Non: [! EXPRESSION]
650) this.width=650; "src=" Http://images0.cnblogs.com/blog2015/764880/201506/021801141489597.png "/>
Linux Conditional Test Statement