145 lines
3.4 KiB
Raw Normal View History

.Dd 2015-10-08
.Dt FIND 1
.Os sbase
.Nm find
2015-08-04 15:58:15 +00:00
.Nd find files
.Op Fl H | L
.Ar path Op ...
.Op Ar expression
walks a file hierarchy starting at each
.Ar path
and applies the
.Ar expression
to each file encountered.
.Bl -tag -width Ds
.It Fl H
Dereference symbolic links provided as
.Ar path .
.It Fl L
Dereference all symbolic links encountered.
2015-08-04 15:58:15 +00:00
.Ar expression
is a combination of the following primaries and boolean operators.
In the following descriptions the number n can be replaced by +n, n, or
-n, to mean more than, exactly, or less than n respectively.
2015-08-04 15:58:15 +00:00
.Ss Primaries
.Bl -tag -width Ds
.It Fl name Ar pattern
True if the name of the file matches the given pattern.
.It Fl path Ar pattern
True if the path to the file matches the given pattern.
.It Fl nouser
True if the file belongs to a user for which getpwuid() returns NULL.
.It Fl nogroup
True if the file belongs to a group for which getgrgid() returns NULL.
.It Fl xdev
Do not enter directory on a different device.
2015-08-04 15:58:15 +00:00
.It Fl prune
Do not enter directory.
2015-08-04 15:58:15 +00:00
.It Fl perm Ar mode
True if permissions on the file match mode.
Mode is a symbolic mode as used in chmod.
A leading '-' in mode checks that at least all bits in mode are set in
permissions for file.
Without the leading '-' the permissions for file must exactly match
2015-08-04 15:58:15 +00:00
.It Fl type Ar t
True if file is of type specified by
.Ar t .
.Bl -tag -width Ds
.It Ar b
block special
.It Ar c
character special
.It Ar d
.It Ar l
symbolic link
.It Ar p
.It Ar f
regular file
.It Ar s
.It Fl links Ar n
True if file has
.Ar n
.It Fl user Ar name
True if file belongs to user
.Ar name .
.It Fl group Ar name
True if file belongs to group
.Ar name .
.It Fl size Ar n[c]
True if file size in 512 byte sectors (rounded up), or bytes (if
.Ar c
is given), is
.Ar n .
.It Fl atime n
True if file access time is
.Ar n
.It Fl ctime
True if file status change time is
.Ar n
.It Fl mtime
True if file modified time is
.Ar n
.It Fl exec Ar cmd [arg ...] \&;
Execute cmd with given arguments, replacing each {} in argument list
with the current file.
True if cmd exits with status 0.
2015-08-04 15:58:15 +00:00
.It Fl exec Ar cmd [arg ...] {} +
Add as many files as possible to argument list and execute when the list
is full or all files have been found.
2015-08-04 15:58:15 +00:00
.It Fl ok Ar cmd [arg ...] \&;
Prompt the user on each file encountered whether or not to execute cmd
as with -exec.
True if the user responds yes and cmd exits with status 0, false
2015-08-04 15:58:15 +00:00
.It Fl print
Print the path to the current file.
2015-08-04 15:58:15 +00:00
.It Fl newer Ar file
True if the modification time of the current file is newer than that of
the provided file.
.It Fl depth
Causes find to evaluate files within in a directory before the directory
2015-08-04 15:58:15 +00:00
.Ss Operators
In order of decreasing precedence
.Bl -tag -width Ds
.It Ar \&( expression \&)
True if expression is true.
.It Ar \&! expression
True if expression if false.
.It Ar expression [ Fl a ] Ar expression
True if both expressions are true.
Second expression is not evaluated if first expression is false.
2015-08-04 15:58:15 +00:00
.Fl a
is implied if there is no operator between primaries.
.It Ar expression Fl o Ar expression
True if either expression is true.
Second expression is not evaluated if first expression is true.
2015-08-04 15:58:15 +00:00
If no expression is supplied, -print is used.
If an expression is supplied but none of -print, -exec, or -ok is
supplied, then -a -print is appended to the expressions.