find - Find files
find [ options ] [ pathname… ] [ >output ]
Find recursively descends the directory hierarchy for one or more pathnames given, seeking all files that match specified search options. If a pathname is ‘/’, the root prefix is assumed.
Without options, find lists all the files in the current working directory and every directory found within.
A number of useful examples are given at the end of this manual entry.
Consider all files when reading directories. This includes visible and invisible files. By default, only visible files are considered.
Report a count of matching files when find is done.
Search only through a specified number of directory levels. The default is 16 levels deep.
Use information obtained from file for making comparisons with
searched files. Comparison is made for all search selectors
except for file names (-N). Example:
find -f foo -T =
This finds all files within the current directory tree that match the file type for the file “foo”. Using ‘=’ with a selector tells find to use the appropriate information from the file specified with -f. (Selectors are discussed below).
Consider only invisible (hidden) files when reading directories.
Specify pattern when printing matched files. The contents of
pattern are printed for each match, and imbedded ‘%’ characters
are used to substitute special information:
% - displays nothing
%f - fully qualified path to file
%n - name of file
%p - parent path to file
%s - size of file in blocks
%x - partial path to file excluding source prefix
Combinations of these options can be included in the pattern (e.g., the pattern “%n found in %p” displays “bar found in /a/usr/foo/” when the complete pathname is “/a/usr/foo/bar”).
By default, find displays the path to each file.
Quit after the specified matches are found. The default is to never quit until all paths have been searched.
Include the time (hh:mm) whenever a date match is made. By default, only the date (mm/dd/yy) is used in searches.
Displays progress information on each directory being searched.
The following selectors are used to specify matching files:
Match files that have attributes as specified by these characters:
d = Destroy (file can be removed)
n = Rename (file can be renamed)
b = Backup (file needs a backup)
i = Invisible (file is hidden)
w = Write (file can be written to)
r = Read (file can be read)
Match files by a name pattern. The the pattern must be in lowercase, and may contain ‘*’ to match wildcard portions. Thus, “-N *baz*” finds all file names containing “baz”.
Match files by type (a decimal value from 0 to 255).
Match files by auxtype (a decimal value from 0 to 65535).
Match files by size in 512-byte blocks.
Match files bigger than the size given in blocks.
Match files smaller than the size given in blocks.
Match files modified on date. date is a string in one of the forms
mm/dd/yy "mm/dd/yy hh:mm" "mm/dd/yy hh:mm AM" "mm/dd/yy hh:mm PM"
representing the month (1-12), day (1-31), year (0-99), hour (0-23), and minute (0-59). The string must be quoted if it contains a space. A period (.) indicates the current date and time.
If the time is omitted, midnight is assumed. If the time is significant in date comparisons, include the -t option as described above.
Match files older than date.
Match files younger (newer) than date.
An equal sign (=) may be the argument to a selector if the -f option is used. See -f above for more details.
Prefixing a selector with ‘!’ inverts (or negates) the match result. That is, “-!N” means to match all files that do not match a particular name pattern, thus “-!N *baz*” finds all files that do not contain the pattern “baz” in their names.
Multiple search selectors can be combined. As long as each selector matches, find continues to apply selection criteria to the current file. When all selectors have been processed successfully for a file, it is considered to be a match.
If the very last argument given begins with ‘>’, find redirects all of its output, except verbose progress reports, into the filename which follows. This is excellent for creating scripts containing commands which act on all the matched files.
To find all executable programs younger (newer) than $/bin/man:
find -f $/bin/man -Y = $path
To build and run a script that removes all files beginning with “finder.”:
find -N finder.* -p "echo found %n in %p; rm %f" / >killfndr source killfndr
To find all files in $/usr that are not named “login”, “signature”, nor “mailrc”, and are not directory files:
find -!N login -!N signature -!N mailrc -!T 15 $/usr
To report only the count of all invisible files in the current directory level:
find -i -d 1 -c -p %
To find all files that need to be backed up, showing their sizes:
find / -a -A b -p "%f (%s blocks)"
To find all files modified between January and February in 1994:
find / -a -Y "01/01/94" -O "02/01/94"
grep(C), setfile(C), version(C), whereis(C)