find

Name

find -- search for files in a directory hierarchy

Description

find is as specified in the SUS but with additional options as specified below.

LSB Deprecated Differences

The behaviors specified in this section are expected to disappear from a future version of the LSB; applications should only use the non-LSB-deprecated behaviors.

-daystart

measures times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the beginning of today rather than from 24 hours ago.

-follow

dereferences symbolic links. Implies -noleaf.

-maxdepth levels

descends at most levels (a non-negative integer) levels of directories below the command line arguments. -maxdepth 0 means only apply the tests and actions to the command line arguments.

-mindepth levels

applies no tests or actions at levels less than levels (a non-negative integer). -mindepth 1 means process all files except the command line arguments.

-mount

is equivalent to -xdev as specified in the SUS.

-noleaf

does not optimize by assuming that directories contain 2 fewer subdirectories than their hard link count.

-version

prints the find version number and exits.

-amin n

displays files last accessed n minutes ago.

-anewer file

displays files last accessed more recently than file was modified. -anewer is affected by -follow only if -follow comes before -anewer on the command line.

-cmin n

displays files with status last changed n minutes ago.

-cnewer file

displays files with status last changed more recently than file was modified. -cnewer is affected by -follow only if -follow comes before -cnewer on the command line.

-empty

displays files that are empty and are either regular or directory files.

-false

is always false.

-fstype type

displays files on a filesystem of type type.

-gid n

displays files with numeric group ID of n.

-ilname pattern

is like -lname, but the match is case-insensitive.

-iname pattern

is like -name, but the match is case-insensitive.

-inum n

displays files with inode number of n.

-ipath path

is like -path, but the match is case-insensitive.

-iregex pattern

is like -regex, but the match is case-insensitive.

-lname

displays files that are symbolic links whose contents match shell pattern pattern. The metacharacters do not treat / or . specially.

-mmin n

displays files with data last modified n minutes ago.

-nouser

displays files with numeric user ID corresponding to no user.

-nogroup

displays files with numeric group ID corresponding to no group.

-path pattern

displays files with name matching shell pattern pattern.

-perm +mode

displays files with any of the permission bits mode set.

-regex

displays files with names matching regular expression pattern. This is a match on the whole path, not a search.

-true

is always true.

-type c

supplements types as specified in the SUS with the letters l and s (symbolic links and sockets, respectively).

-uid n

displays files with numeric user ID of n.

-used

displays files last accessed n days after status was last changed.

-xtype c

is equivalent to -type unless the file is a symbolic link. For symbolic links: if -follow has not been given, true if the file is a link to a file of type c; if -follow has been given, true if c is l. In other words, for symbolic links, -xtype checks the type of the file that -type does not check.

-fls file

is true. Is like -ls but write to file like -fprint.

-fprint file

is true. Prints the full file name into file file. If file does not exist when find is run, it is created; if it does exist, it is truncated. The file names `/dev/stdout' and `/dev/stderr' are handled specially; they refer to the standard output and standard error output, respectively.

-fprint0 file

is true. Is like -print0 but write to file like -fprint.

-fprintf file format

is true. Like -printf but write to file like -fprint.

-print0

is true. Prints the full file name on the standard output, followed by a null character. This allows file names that contain newlines to be correctly interpreted by programs that process the find output.

-printf format

is true. Prints format on the standard output, interpreting \ escapes and % directives. Field widths and precisions can be specified as with the printf C function. Unlike -print, -printf does not add a newline at the end of the string. The escapes and directives are:

\a

alarm bell.

\b

backspace.

\c

stops printing from this format immediately and flushes the output.

\f

form feed.

\n

newline.

\r

carriage return.

\t

horizontal tab.

\v

vertical tab.

\\

literal backslash (\).

%%

literal percent sign.

%a

last file access time in the format returned by the C ctime function.

%Ak

last file access time in the format specified by k, which is either @ or a directive for the C strftime function. The possible values for k are listed below; some of them might not be available on all systems, due to differences in strftime between systems.

@

seconds since Jan. 1, 1970, 00:00 GMT.

H

hour (00..23).

I

hour (01..12).

k

hour ( 0..23).

l

hour ( 1..12).

M

minute (00..59).

p

locale's AM or PM.

r

time, 12-hour (hh:mm:ss [AP]M).

S

second (00..61).

T

time, 24-hour (hh:mm:ss).

X

locale's time representation (H:M:S).

Z

time zone (e.g., EDT), or nothing if no time zone is determinable.

a

locale's abbreviated weekday name (Sun..Sat).

A

locale's full weekday name, variable length (Sunday..Saturday).

b

locale's abbreviated month name (Jan..Dec).

B

locale's full month name, variable.

c

locale's date and time (Sat Nov 04 12:02:33 EST 1989).

d

day of month (01..31).

D

date (mm/dd/yy).

h

same as b.

j

day of year (001.366).

m

month (01..12).

U

week number of year with Sunday as first day of week (00..53).

w

day of week (0..6).

W

week number of year with Monday as first day of week (00..53).

x

locale's date representation (mm/dd/yy).

y

last two digits of year (00..99).

Y

year (1970...).

%b

file's size in 512-byte blocks (rounded up).

%c

last file status change time in the format returned by the C ctime function.

%Ck

last file status change time in the format specified by k, which is the same as for %A.

%d

file's depth in the directory tree; 0 means the file is a command line argument.

%f

file's name with any leading directories removed (only the last element).

%F

type of the filesystem the file is on; this value can be used for -fstype.

%g

file's group name, or numeric group ID if the group has no name.

%G

file's numeric group ID.

%h

leading directories of file's name (all but the last element).

%H

mommand line argument under which file was found.

%i

file's inode number (in decimal).

%k

file's size in 1K blocks (rounded up).

%l

object of symbolic link (empty string if file is not a symbolic link).

%m

file's permission bits (in octal).

%n

number of hard links to file.

%p

file's name.

%P

file's name with the name of the command line argument under which it was found removed.

%s

file's size in bytes.

%t

file's last modification time in the format returned by the C ctime function.

%Tk

file's last modification time in the format specified by k, which is the same as for %A.

%u

file's user name, or numeric user ID if the user has no name.

%U

file's numeric user ID.

-ls

is true. Lists current file in ls -dils format on standard output. The block counts are of 1K blocks, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

Extra Operators

The following operators are supported in order of decreasing precedence and override what is specified in the SUS.

( expr )

force precedence.

! expr

true if expr is false

-not expr

same as ! expr.

expr1 expr2

and (implied); expr2 is not evaluated if expr1 is false.

expr1 -a expr2

same as expr1 expr2.

expr1 -and expr2

same as expr1 expr2.

expr1 -o expr2

or; expr2 is not evaluated if expr1 is true.

expr1 -or expr2

same as expr1 -o expr2.

expr1, expr2

list; both expr1 and expr2 are always evaluated. The value of expr1 is discarded; the value of the list is the value of expr2.