Saturday, July 9, 2011

perl file test syntax

It checks whether the directory exists or not. There are many more
file test operations available, such as below:

  1. -r File is readable by effective uid/gid.
  2. -w File is writable by effective uid/gid.
  3. -x File is executable by effective uid/gid.
  4. -o File is owned by effective uid.
  5. -R File is readable by real uid/gid.
  6. -W File is writable by real uid/gid.
  7. -X File is executable by real uid/gid.
  8. -O File is owned by real uid.
  9. -e File exists.
 10. -z File has zero size (is empty).
 11. -s File has nonzero size (returns size in bytes).
 12. -f File is a plain file.
 13. -d File is a directory.
 14. -l File is a symbolic link.
 15. -p File is a named pipe (FIFO), or Filehandle is a pipe.
 16. -S File is a socket.
 17. -b File is a block special file.
 18. -c File is a character special file.
 19. -t Filehandle is opened to a tty.
 20. -u File has setuid bit set.
 21. -g File has setgid bit set.
 22. -k File has sticky bit set.
 23. -T File is an ASCII text file (heuristic guess).
 24. -B File is a "binary" file (opposite of -T).
 25. -M Script start time minus file modification time, in days.
 26. -A Same for access time.
 27. -C Same for inode change time (Unix, may differ for other platforms)

No comments: