themactep.com

A home of miscellaneous projects by Paul Philippov.

Notes

How to check file type in shell

Use test -? filename or [ -? filename ], where -? parameter is one of the following:

-f a regular file
-d a directory
-e any type of file
-c a character file
-r a readable file
-w a writable file
-x an executable file
-p a pipe
-S a socket
-s a non-zero file
-L a symbolic link
-g a file with group id flag set
-G a file with the same group id that is in process
-k a file with a sticky bit flag