文件 含义
-r True if file exists and is readable
-w True if file exists and is writable
-x True if file exists and is executable
-f True if file exists and is a regular file
-d True if file exists and is a directory
-c True if file exists and is a character special file
-b True if file exists and is a block special file
-p True if file exists and is a named pipe (FIFO)
-u True if file exists and is a SETUID file
-g True if file exists and is a SETGID file
-k True if file exists and the sticky bit is set
-s True if file exists and has a size greater than zero
逻辑 含义
! Not
-a And
-o Or (has lower precedence that -a)
( ) Parentheses for grouping
数值 含义
-ne Not equal
-eq Equal
-gt Greater then
-ge Greater than or equal
-le Less than or equal
-lt Less than
其他 含义
-z str True if string length is zero
-n str True if string length is non-zero
str1 = str2 True if strings are identical. Note that this uses a single = symbol unlike C’s equality operator.
str1 != str2 True if strings are not identical
str True if string is not the null string