1. string Judgments
STR1 = str2 |
True when two strings have the same content, length |
Str1! = str2 |
True when strings str1 and str2 are unequal |
-N str1 |
True when the length of a string is greater than 0 (string non-null) |
-Z str1 |
True when the length of the string is 0 (empty string) |
Str1 |
True when the string str1 is non-empty |
2. Judgment of numbers
Int1-eq Int2 |
Two numbers equal to True |
Int1-ne Int2 |
Two numbers are true. |
INT1-GT Int2 |
Int1 greater than Int2 is true |
Int1-ge Int2 |
Int1 greater than or equal to Int2 true |
Int1-lt Int2 |
Int1 less than Int2 is true |
Int1-le Int2 |
Int1 less than or equal to Int2 true |
3. Judgment of documents
-R File |
User-readable as true |
-W File |
User can write as true |
-X File |
User can perform a true |
-F File |
File is true for regular files |
-D File |
File is directory-True |
-C file |
File is true for character special files |
-B File |
File is true for block special files |
-S file |
File non-0 o'clock is true |
-T file |
True if the specified device is terminal when the file descriptor (default is 1) |
4. complex logic judgment
End
[-A file] is true if file exists.
[-B file] True if file exists and is a block special file.
[-C file] True if file exists and is a word special.
[-D file] True if file exists and is a directory.
[-E File] True if file exists.
[-F file] True if file exists and is a normal file.
[-G file] True if file exists and Sgid has been set. [-H file] True if file exists and is a symbolic connection.
[-K file] True if file exists and the sticky bit has been set.
[-P file] If file exists and is a name pipe (f if O) is true.
[-R File] True if file exists and is readable.
[-S file] True if file exists and the size is not 0.
[-T FD] true if the file descriptor FD is open and points to a terminal.
[-u file] True if file exists and suid (set user ID) is set.
[-W file] True if file exists and is writable.
[-X file] True if file exists and is executable.
[-o file] True if file exists and is a valid user ID.
[-G file] True if file exists and is a valid user group.
[-L file] True if file exists and is a symbolic connection.
[-N file] If file exists and has been mod if IED since it is last read is true.
[-S file] True if file exists and is a socket.
[File1-nt FILE2] If FILE1 have been changed more recently than FILE2, or if file1exists and FILE2 does not is true.
[File1-ot FILE2] If FILE1 is older than FILE2, or FILE2 exists and FILE1 does not exist, it is true.
[File1-ef FILE2] True if FILE1 and FILE2 point to the same device and node number.
[-O Optionname] true if the shell option "Optionname" is turned on.
[-Z STRING] "STRING" is true if the length is zero.
[-N STRING] or [string] "string" is true if the length is not 0 non-zero.
[STRING1 = = STRING2] If 2 strings are the same. "=" May is used instead of "= =" for strict POSIX compliance is true.
[STRING1! = STRING2] True if the strings are not equal.
[STRING1 < STRING2] if "STRING1" sorts before "STRING2" lexicographically in the Currentlocale is true.
[STRING1 > STRING2] If "STRING1" sorts after "STRING2" lexicographically in thecurrent locale is true.
Shell condition judgment