First, write some basic syntax:
1. String judgment
Str1 = str2
True when two strings have the same content and length
Str1! = Str2
True when str1 and str2 are different
-N str1: true when the length of a string is greater than 0 (the string is not empty)
-Z str1
True (empty string) when the string length is 0)
Str1 is true when str1 is not empty
2. digit judgment
Int1-EQ
Int2 two numbers are equal to true
Int1-ne int2 two numbers are not true
Int1-GT
Int2 int1 greater than int2 true
Int1-ge int2 int1 greater than or equal to int2 true
Int1-lt
Int2 int1 smaller than int2 true
Int1-Le int2 int1 smaller than or equal to int2 true
3. File judgment
-R
File user readable to true
-W file users can write to true
-X file user executable is true
-F
The file is a regular file and is true.
-D file: the directory is true.
-C file: the special character file is true.
-B
The file is a special block file that is true.
-S file is true if the file size is not 0
-T
File is true when the device specified by the file descriptor (1 by default) is a terminal.
3. complex logic judgment
-
And
-O or
! Non