FLAG | MEANING |
---|---|
-e | file exists |
-a | file exists (deprecated, don't use) |
-f | file is a regular file (not a directory or /dev - device file) |
-s | file is not zero size |
-d | file is a directory |
-b | file is a block device (see below) |
-c | file is a character device (see below) |
-p | file is a pipe |
-h | file is a symbolic link |
-L | file is a symbolic link |
-S | file is a socket |
-t | file (descriptor) is associated with a terminal device This test option may be used to check whether the stdin [ -t 0 ] or stdout [ -t 1 ] in a given script is a terminal. |
-r | file has read permission (for the user running the test) |
-w | file has write permission (for the user running the test) |
-x | file has execute permission (for the user running the test) |
-g | set-group-id (sgid) flag set on file or directory If a directory has the sgid flag set, then a file created within that directory belongs to the group that owns the directory, not necessarily to the group of the user who created the file. This may be useful for a directory shared by a workgroup. |
-u | setuser-id (suid) flag set on file |
-k | sticky bit set |
-O | you are owner of file |
-G | group-id of file same as yours |
-N | file modified since it was last read |
f1 -nt f2 | file f1 is newer than f2 |
f1 -ot f2 | file f1 is older than f2 |
f1 -ef f2 | files f1 and f2 are hard links to the same file |
! | "not" -- reverses the sense of the tests above (returns true if condition absent). |
Created
February 10, 2023 07:57
-
-
Save pkutaj/7c771c1da0ef1b45213686885fef694f to your computer and use it in GitHub Desktop.
Reference for Bash File Test Operators
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment