File type tests

posted Sep 10, 2010, 7:28 AM by Sachchida Ojha   [ updated Feb 12, 2012, 8:52 PM by Sachchida Ojha ]

These options test for particular types of files. All cases will only return True (0) if the file exists.

`-b file':True if file is a Block special device.
`-c file':True if file is a Character special device.
`-d file':True if file is a Directory.
`-e file':True if file Exists.
`-f file':True if file is a regular File.
`-g file':True if file has its set-group-id bit set.
`-G file':True if file is owned by the current effective group id.
`-k file':True if file has its "sticky" bit set.
`-h file':
`-L file':True if file is a symbolic Link.
`-O file':True if file is owned by the current effective user id.
`-p file':True if file is a named Pipe.
`-r file':True if file is readable.
`-S file':True if file is a Socket.
`-s file':True if file has a Size greater than zero.
`-t [FD]':True if FD is opened on a terminal.  If FD is omitted, it defaults to 1 (standard output).
`-u file':True if file has its set-user-id bit set.
`-w file':True if file is writable.
`-x file':True if file is executable.
`file1 -ef file2':True if file1 and file2 have the same device and inode numbers,i.e., if they are hard links to each other.

Comments