Home >Backend Development >Python Tutorial >Summary of linux script judgment conditions (must read)
As shown below:
-b file is true if the file exists and is a block special file
-c file is true if the file exists and is a character special file
-d file True if the file exists and is a directory
-e file True if the file exists
-f file True if the file exists and is a rule file
- g file true if the file exists and the SGID bit is set
-h file true if the file exists and is a matching link
-k file true if the file exists and the "sticky" bit is set The value of
-p file is true if the file exists and is a named pipe
-r file is true if the file exists and is readable
-s file is true if the file exists and its size is greater than Zero, true
-u file True if the file exists and the SUID bit is set
-w file True if the file exists and is writable
-x file True if the file exists and is writable True if executed
-o file True if the file exists and is owned by a valid user ID
-z string True if the string length is 0
-n string If If the string length is not 0, then it is true
string1 = string2 If the two strings are equal, it is true
string1 != string2 If the two strings are not equal, it is true
int1 -eq int2 True if int1 is equal to int2
int1 -ne int2 True if int1 is not equal to int2
int1 -lt int2 True if int1 is less than int2
int1 -le int2 if int1 is less than or equal to int2, then it is true
int1 -gt int2 If int1 is greater than int2, it is true
int1 -ge int2 If int1 is greater than or equal to int2, it is true
!expr If expr is False then the compound expression is true. expr can be any valid test expression
expr1 -a expr2 If both expr1 and expr2 are true, then the integer is true
expr1 -o expr2 If either expr1 or expr2 is true, then the integer is true
The above summary of Linux script judgment conditions (must read) is all the content shared by the editor. I hope it can give you a reference, and I hope you will support the PHP Chinese website.
For more linux script judgment condition summary (must read) related articles, please pay attention to the PHP Chinese website!