2.7 Type

Test: -type c

True if the file is of type c:

b

block (buffered) special

c

character (unbuffered) special

d

directory

p

named pipe (FIFO)

f

regular file

l

symbolic link; if ‘-L’ is in effect, this is true only for broken symbolic links. If you want to search for symbolic links when ‘-L’ is in effect, use ‘-xtype’ instead of ‘-type’.

s

socket

D

door (Solaris)

As a GNU extension, multiple file types can be provided as a combined list separated by comma ‘,’. For example, ‘-type f,d,l’ is logically interpreted as ‘( -type f -o -type d -o -type l )’.

Test: -xtype c

This test behaves the same as ‘-type’ unless the file is a symbolic link. If the file is a symbolic link, the result is as follows (in the table below, ‘X’ should be understood to represent any letter except ‘l’):

-P -xtype l

True if the symbolic link is broken or has an infinite loop

-P -xtype X

True if the (ultimate) target file is of type ‘X’.

-L -xtype l

Always true

-L -xtype X

False unless the symbolic link is broken or has an infinite loop

In other words, for non-broken symbolic links, ‘-xtype’ checks the type of the file that ‘-type’ does not check. For broken symbolic links (or loops), ‘-xtype’ behaves like ‘-type’ does. Symbolic links pointing to things the user has no access to are not considered to be broken.

The ‘-H’ option also affects the behaviour of ‘-xtype’. When ‘-H’ is in effect, ‘-xtype’ behaves as if ‘-L’ had been specified when examining files listed on the command line, and as if ‘-P’ had been specified otherwise. If neither ‘-H’ nor ‘-L’ was specified, ‘-xtype’ behaves as if ‘-P’ had been specified.

See Symbolic Links, for more information on ‘-follow’ and ‘-L’.