find - find files


find [ options ] [ path ... ] [ options ]


find recursively descends the directory hierarchy for each path and applies an option expression to each file in the hierarchy. -print is implied if there is no action that generates output. The expression starts with the first argument that matches [(-!]. Option expressions may occur before and/or after the path arguments. For numeric arguments n , +n means >n, -n means <n, and n means exactly n.



Equivalent to \(. Begin nested expression.
Equivalent to \). End nested expression.

Equivalent to `\&'. expr1 -and expr2: Both expr1 and expr2 must evaluate true. This is the default operator for two expression in sequence.
-amin minutes

File was last accessed minutes minutes ago.
-anewer file

File was last accessed more recently than file was modified.
-atime days

File was last accessed days days ago.

Turns off -silent; enables inaccessible file and directory warnings. This is the default.

Chop leading ./ from printed pathnames.
-cmin minutes

File status changed minutes minutes ago.
-cnewer file

File status changed more recently than file was modified.
-codes path

Sets the find or locate(1) database path. See updatedb(1) for a description of this database.

Equivalent to `,'. Joins two expressions; the status of the first is ignored.

File is written as a binary format cpio(1) file entry.
-ctime days

File status changed days days ago.

Measure times (-amin -atime -cmin -ctime -mmin -mtime) from the beginning of today. The default is 24 hours ago.

Process directory contents before the directory itself.

A directory with size 0 or with no entries other than . or .., or a regular file with size 0.
-exec command ... ; | command ... {} +

Execute command ...; true if 0 exit status is returned. Arguments up to ; are taken as arguments to command. The string `{}' in command ... is globally replaced by the current filename. The command is executed in the directory from which find was executed. The second form gathers pathnames until ARG_MAX is reached, replaces {} preceding + with the list of pathnames, one pathname per argument, and executes command ... pathname ..., possibly multiple times, until all pathnames are exhausted.

Always false.
-fast pattern

Searches the find or locate(1) database for paths matching the ksh(1) pattern. See updatedb(1) for details on this database. The command line arguments limit the search and the expression, but all depth options are ignored. The remainder of the expression is applied to the matching paths.
-fls file

Like -ls except the output is written to file.
-fprint file

Like -print except the output is written to file.
-fprint0 file

Like -print0 except the output is written to file.
-fprintf file format

Like -printf except the output is written to file.
-fprintx file

Like -printx except the output is written to file.
-fstype type

File is on a filesystem type. See df(1) or -printf %F for local filesystem type names.
-group|gid id

File group id name or number matches id.

Ignore case in all pattern match expressions.
-ilname pattern

A case-insensitive version of -lname pattern.
-iname pattern

A case-insensitive version of -name pattern.
-inum number

File has inode number number.
-ipath pattern

A case-insensitive version of -path pattern.
-iregex pattern

A case-insensitive version of -regex pattern.
-level level

Current level (depth) is level.
-links number

File has number links.
-lname pattern

File is a symbolic link with text that matches pattern.

File is on a local filesystem.

Follow symbolic links.
List the current file in `ls -dils' format to the standard output.
-magic pattern

File magic number matches the file(1) and magic(3) description pattern.
-maxdepth level

Descend at most level directory levels below the command line arguments. -maxdepth 0 limits the search to the command line arguments.

-logical for command line arguments, -physical otherwise.
-mime type/subtype

File mime type matches the pattern type/subtype.
-mindepth level

Do not apply tests or actions a levels less than level. -mindepth 1 processes all but the command line arguments.
-mmin minutes

File was modified minutes minutes ago.

Do not descend into directories in different filesystems than their parents.
-mtime days

File was modified days days ago.
-name pattern

File base name (no directory components) matches pattern.

File is written as a character format cpio(1) file entry.
-newer file

File was modified more recently than file.

There is no group name matching the file group id.

Disable -physical leaf file stat(2) optimizations. Only required on filesystems with . and .. as the first entries and link count not equal to 2 plus the number of subdirectories.
-not expr: inverts the truth value of expr.

There is no user name matching the file user id.
-ok command ... \;

Like -exec except a prompt is written to the terminal. If the response does not match `[yY].*' then the command is not run and false is returned.

Equivalent to `\|'. expr1 -or expr2: expr2 is not evaluated if expr1 is true.
-path pattern

File path name (with directory components) matches pattern.
-perm mode

File permission bits tests; mode may be octal or symbolic as in chmod(1). mode: exactly mode; -mode: all mode bits are set; +mode: at least one of mode bits are set.

Do not follow symbolic links. This is the default.

Process directories before and and after the contents are processed.

Print the path name (including directory components) to the standard output, followed by a newline.

Like -print, except that the path is followed by a NUL character.
-printf format

Print format format on the standard output, interpreting `\' escapes and `%' directives. printf(3) field width and precision are interpreted as usual, but the directive characters have special interpretation. ----- escape sequences ----- \a
alert \b
backspace \f
form feed \n
newline \t
horizontal tab \v
vertical tab \xnn
hexadecimal character nn \nnn
octal character nnn ----- format directives ----- %%
literal % %a
access time in ctime(3) format %Ac
access time is strftime(3) %c format %b
file size in 512 byte blocks %c
status change time in ctime(3) format %Cc
status change time is strftime(3) %c format %d
directory tree depth; 0 means command line argument %f
file base name (no directory components) %F
filesystem type name; use this for -fstype %g
group name, or numeric group id if no name found %G
numeric group id %h
file directory name (no base component) %H
command line argument under which file is found %i
file inode number %k
file size in kilobytes %l
symbolic link text, empty if not symbolic link %m
permission bits in octal %n
number of hard links %p
full path name %P
file path with command line argument prefix deleted %s
file size in bytes %t
modify time in ctime(3) format %Tc
modify time is strftime(3) %c format %u
user name, or numeric user id if no name found %U
numeric user id %x
%p quoted for xargs(1) %X
%P quoted for xargs(1)

Print the path name (including directory components) to the standard output, with xargs(1) special characters preceded by \, followed by a newline.

Ignored if -depth is given, otherwise do not descend the current directory.
-regex pattern

Path name matches the anchored regular expression pattern, i.e., leading ^ and traling $ are implied.

Reverse the -sort sense.

Do not warn about inaccessible directories or symbolic link loops.
-size number[bcgkm]

File size is number units (b: 512 byte blocks, c: characters g: 1024*1024*1024 blocks, k: 1024 blocks, m: 1024*1024 blocks.) Sizes are rounded to the next unit.
-sort option

Search each directory in -option sort order, e.g., -name sorts by name, -size sorts by size.
-test seconds

Set the current time to seconds since the epoch. Other implementation defined test modes may also be enabled.

Always true.
-type type

File type matches type:
block special
character special
regular file
symbolic link
named pipe (FIFO)
-used days

File was accessed days days after its status changed.
-user|uid id

File user id matches the name or number id.
-xargs command ... \;

Like -exec except as many file args as permitted are appended to command ... which may be executed 0 or more times depending on the number of files found and local system exec(2) argument limits.
-xtype type

Like -type, except if symbolic links are followed, the test is applied to the symbolic link itself, otherwise the test is applied to the pointed to file. Equivalent to -type if no symbolic links are involved.


If no commands were executed (-exec, -xargs) the exit status is 1 if errors were detected in the directory traversal and 0 if no errors were ecountered. Otherwise the status is:
All command executions returned exit status 0.

A command line meeting the specified requirements could not be assembled, one or more of the invocations of command returned non-0 exit status, or some other error occurred.
command was found but could not be executed.
command was not found.



Path name of the locate(1) database.

Alternate path name of locate(1) database.



Default locate(1) database.


In order to access the slocate(1) database the find executable must be setgid to the slocate group.


cpio(1), file(1), locate(1), ls(1), sh(1), slocate(1), test(1), tw(1), updatedb(1), xargs(1), stat(2)



find (AT&T Research) 2012-04-11

Glenn Fowler <>

David Korn <>

Copyright © 1989-2012 AT&T Intellectual Property