Outline
Operators | Explanation | For example |
---|---|---|
-e file | Detect file (including directory) exists, and if so, it returns true. | [-E $ file] returns true. |
-s file | Detecting whether the file is empty (the file size is greater than 0), is not empty return true. | [-S $ file] returns true. |
-d file | Detecting whether the file is a directory, and if so, it returns true. | [-D $ file] returns false. |
-f file | Detecting whether the file is a regular file (neither catalog nor the device file), and if so, it returns true. | [-F $ file] returns true. |
-b file | Detecting whether the file is a device file block, if so, it returns true. | [-B $ file] returns false. |
-c file | Detecting whether the file is a character file, and if so, it returns true. | [-C $ file] returns false. |
-p file | Detecting whether the file is a named pipe, and if so, it returns true. | [-P $ file] returns false. |
-r file | Detecting whether the file is readable, and if so, it returns true. | [-R $ file] returns true. |
-w file | Detecting whether the file can be written, and if so, it returns true. | [-W $ file] returns true. |
-x file | Detecting whether the file is executable, and if so, it returns true. | [-X $ file] returns true. |
-g file | Detecting whether the file has the SGID bit, and if so, it returns true. | [-G $ file] returns false. |
-u file | Detecting whether the file has the SUID bit, and if so, it returns true. | [-U $ file] returns false. |
-k file | Detecting whether a file has the sticky bit (Sticky Bit), and if so, it returns true. | [-K $ file] returns false. |
note:
- File size has been not empty