If you are only interested in files of a certain type, use the -type argument, followed by one of the characters in Table 17.1 [some versions of find don't have all of these -JP ].
Character
|
Meaning
|
|---|---|
| b | Block special file ("device file") |
| c | Character special file ("device file") |
| d | Directory |
| f | Plain file |
| l | Symbolic link |
| p | Named pipe file |
| s | Socket |
Unless you are a system administrator, the important types are directories, plain files, or symbolic links (i.e., types
d
,
f
, or
l
).
Using the -type operator, another way to list files recursively is:
xargs |
%
|
|---|
It can be difficult to keep track of all the symbolic links in a directory. The next command will find all the symbolic links in your home directory and print the files that your symbolic links point to. [
$NF
gives the last field of each line, which holds the name a symlink points to.
-JP
] If your
find
doesn't have a
-ls
operator, pipe to
xargs ls -l
as above.
%find $HOME -type l -ls | awk '{print $NF}'
-