Shell judgment
#按照文件类型进行判断
-B To determine if the file exists and whether it is a fast device file (The block device file is true)
-C Determines whether the file exists and whether it is a character device file (the character device file is true)
-D to determine if the file exists and is a directory file (the directory is true)
-E to determine if a file exists, exists as true
-F to determine if the file exists and is a normal file (exists as true)
-L to determine if the file exists and is a symbolic link file (the symbolic link file is True)
-P to determine if the file exists and is a pipe file (the pipe file is true)
-S to determine if the file exists and is empty (non-null is true)
-S to determine if the file exists and is a socket file (the socket file is true)
#按照文件权限进行判断
-R to determine if the document has Read permissions
-W to determine if Write permission is available
-X determines whether the executable
#两个文件之间的比较
Files 1-nt File 2 Determine if the modification time of file 1 is newer than file 2 (if new is true)
Files 1-ot File 2 Determine if the modification time of file 1 is older than file 2 (if old is true)
Files 1-ef file 2 Determine whether the file 1 is the same as the inode number of file 2, it can be understood that two files are the same file, this judgment is the best way to judge hard links
#两个整数之间的比较
-eq determine if two values are equal
-ne determine if two values are not equal
-gt Judging whether it is greater than
-lt Judging whether it is less than
-ge judgment is greater than or equal to
-le determine if it is less than or equal
#字符串之间的判断
-Z to determine if the string is empty
-N to determine if the string is non-null
String 1 = = 2 Determine if string 1 is equal to string 2
String 1! = 2 to determine if string 1 is not equal to string 2
#多重条件判断
Judge 1-a judgment 2 logic with, Judge 1 and Judge 2 are set up, the final result is true
Judge 1-o Judge 2 logic or, judging 1 and judging 2 has a set up, the result is true
! The judgment logic does not make the original judgment be reversed
Note: This article only to oneself later study reference
This article is from the "Sunshineboy" blog, make sure to keep this source http://sunshineboy.blog.51cto.com/10310940/1745317
Various judgment grammars in the shell