In Perl, file-test operators are useful for determining the status of a file. Some of the operators below refer to the “real user” which is the User ID specified at login rather than “effectve User ID” which refers to the User ID you are currently working under. The general syntax is -[file-test operator] [operand being tested].
- -b = is operand a block deice
- -c = is operand a character device
- -d = is operand a directory
- -e = does it exist
- -f = is operand an ordinary file
- -g = does operand have its setgid bit set
- -k = does operand have its “sticky bit” set
- -o = is operand owned by the user
- -p = is operand a named pipe
- -r = is operand a readable file
- -s = is operand a non-empty file
- -t = is operand a terminal
- -u = does operand have its setuid set
- -w = is operand a writable file
- -x = is operand an executable file
- -z = is operand an empty file
- -A = how long since operand has been accessed
- -B = is operand a binary file
- -C = how long since operand’s inode accessed
- -M = how long since operand modified
- -O = is operand owned by the “real user” (user who logged in) only
- -R = is operand readable by the “real user” (user who logged in) only
- -S = is operand a socket?
- -T = is operand a text file?
- -W = is operand writable by the “real user” only
- -X = is operand executable by the “real user” only