xref: /freebsd/usr.bin/find/find.1 (revision 2cb640f6b1a70c89bca0ac00dbcb27fc29be7c05)
158540776STim J. Robbins.\" Copyright (c) 1990, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
59b50d902SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
69b50d902SRodney W. Grimes.\"
79b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
89b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
99b50d902SRodney W. Grimes.\" are met:
109b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
119b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
129b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
139b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
149b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
159b50d902SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
169b50d902SRodney W. Grimes.\"    must display the following acknowledgement:
179b50d902SRodney W. Grimes.\"	This product includes software developed by the University of
189b50d902SRodney W. Grimes.\"	California, Berkeley and its contributors.
199b50d902SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
209b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
219b50d902SRodney W. Grimes.\"    without specific prior written permission.
229b50d902SRodney W. Grimes.\"
239b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
249b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
259b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
269b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
279b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
289b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
299b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
309b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
319b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
329b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
339b50d902SRodney W. Grimes.\" SUCH DAMAGE.
349b50d902SRodney W. Grimes.\"
35841484cdSPeter Wemm.\"	@(#)find.1	8.7 (Berkeley) 5/9/95
36c3aac50fSPeter Wemm.\" $FreeBSD$
379b50d902SRodney W. Grimes.\"
384f45d811STim J. Robbins.Dd July 3, 2004
399b50d902SRodney W. Grimes.Dt FIND 1
409b50d902SRodney W. Grimes.Os
419b50d902SRodney W. Grimes.Sh NAME
429b50d902SRodney W. Grimes.Nm find
439b50d902SRodney W. Grimes.Nd walk a file hierarchy
449b50d902SRodney W. Grimes.Sh SYNOPSIS
458fe908efSRuslan Ermilov.Nm
469b50d902SRodney W. Grimes.Op Fl H | Fl L | Fl P
477c1d4b3aSAkinori MUSHA.Op Fl EXdsx
480c101fb2SJoseph Koshy.Op Fl f Ar pathname
49bfd12208SRuslan Ermilov.Op Ar pathname ...
509b50d902SRodney W. Grimes.Ar expression
519b50d902SRodney W. Grimes.Sh DESCRIPTION
52e8937ba0SPhilippe CharnierThe
53e8937ba0SPhilippe Charnier.Nm
54e8937ba0SPhilippe Charnierutility recursively descends the directory tree for each
550c101fb2SJoseph Koshy.Ar pathname
569b50d902SRodney W. Grimeslisted, evaluating an
579b50d902SRodney W. Grimes.Ar expression
58bfd12208SRuslan Ermilov(composed of the
59bfd12208SRuslan Ermilov.Dq primaries
60bfd12208SRuslan Ermilovand
61bfd12208SRuslan Ermilov.Dq operands
62bfd12208SRuslan Ermilovlisted below) in terms
639b50d902SRodney W. Grimesof each file in the tree.
649b50d902SRodney W. Grimes.Pp
659b50d902SRodney W. GrimesThe options are as follows:
66bfd12208SRuslan Ermilov.Bl -tag -width indent
677c1d4b3aSAkinori MUSHA.It Fl E
687c1d4b3aSAkinori MUSHAInterpret regular expressions followed by
697c1d4b3aSAkinori MUSHA.Ic -regex
707c1d4b3aSAkinori MUSHAand
717c1d4b3aSAkinori MUSHA.Ic -iregex
727c1d4b3aSAkinori MUSHAoptions as extended (modern) regular expressions rather than basic
73bfd12208SRuslan Ermilovregular expressions (BRE's).
74bfd12208SRuslan ErmilovThe
757c1d4b3aSAkinori MUSHA.Xr re_format 7
767c1d4b3aSAkinori MUSHAmanual page fully describes both formats.
779b50d902SRodney W. Grimes.It Fl H
783c94f41fSPhilippe CharnierCause the file information and file type (see
799b50d902SRodney W. Grimes.Xr stat 2 )
809b50d902SRodney W. Grimesreturned for each symbolic link specified on the command line to be
819b50d902SRodney W. Grimesthose of the file referenced by the link, not the link itself.
829b50d902SRodney W. GrimesIf the referenced file does not exist, the file information and type will
836df69548SBruce Evansbe for the link itself.
846df69548SBruce EvansFile information of all symbolic links not on
859b50d902SRodney W. Grimesthe command line is that of the link itself.
869b50d902SRodney W. Grimes.It Fl L
873c94f41fSPhilippe CharnierCause the file information and file type (see
889b50d902SRodney W. Grimes.Xr stat 2 )
899b50d902SRodney W. Grimesreturned for each symbolic link to be those of the file referenced by the
909b50d902SRodney W. Grimeslink, not the link itself.
919b50d902SRodney W. GrimesIf the referenced file does not exist, the file information and type will
929b50d902SRodney W. Grimesbe for the link itself.
9347d91ba3SDag-Erling Smørgrav.Pp
9447d91ba3SDag-Erling SmørgravThis option is equivalent to the deprecated
9547d91ba3SDag-Erling Smørgrav.Ic -follow
9647d91ba3SDag-Erling Smørgravprimary.
979b50d902SRodney W. Grimes.It Fl P
983c94f41fSPhilippe CharnierCause the file information and file type (see
999b50d902SRodney W. Grimes.Xr stat 2 )
1009b50d902SRodney W. Grimesreturned for each symbolic link to be those of the link itself.
1013d9a9402SJohn PolstraThis is the default.
1029b50d902SRodney W. Grimes.It Fl X
1033c94f41fSPhilippe CharnierPermit
1049b50d902SRodney W. Grimes.Nm
1059b50d902SRodney W. Grimesto be safely used in conjunction with
1069b50d902SRodney W. Grimes.Xr xargs 1 .
1079b50d902SRodney W. GrimesIf a file name contains any of the delimiting characters used by
108bfd12208SRuslan Ermilov.Xr xargs 1 ,
1099b50d902SRodney W. Grimesa diagnostic message is displayed on standard error, and the file
1109b50d902SRodney W. Grimesis skipped.
111bfd12208SRuslan ErmilovThe delimiting characters include single
112bfd12208SRuslan Ermilov.Pq Dq Li " ' "
113bfd12208SRuslan Ermilovand double
114bfd12208SRuslan Ermilov.Pq Dq Li " \*q "
115bfd12208SRuslan Ermilovquotes, backslash
116bfd12208SRuslan Ermilov.Pq Dq Li \e ,
117bfd12208SRuslan Ermilovspace, tab and newline characters.
118a8d50686STom Rhodes.Pp
119a8d50686STom RhodesHowever, you may wish to consider the
120a8d50686STom Rhodes.Fl print0
121a8d50686STom Rhodesprimary in conjunction with
122e2f8ed51SRuslan Ermilov.Dq Nm xargs Fl 0
123a8d50686STom Rhodesas an effective alternative.
1249b50d902SRodney W. Grimes.It Fl d
1253c94f41fSPhilippe CharnierCause
1268fe908efSRuslan Ermilov.Nm
12754874bb6SRuslan Ermilovto perform a depth-first traversal, i.e., directories
12854874bb6SRuslan Ermilovare visited in post-order and all entries in a directory will be acted
1299b50d902SRodney W. Grimeson before the directory itself.
1309b50d902SRodney W. GrimesBy default,
1318fe908efSRuslan Ermilov.Nm
13254874bb6SRuslan Ermilovvisits directories in pre-order, i.e., before their contents.
1339b50d902SRodney W. GrimesNote, the default is
134bfd12208SRuslan Ermilov.Em not
13554874bb6SRuslan Ermilova breadth-first traversal.
13647d91ba3SDag-Erling Smørgrav.Pp
1371c832963SOliver EikemeierThis option is equivalent to the
13847d91ba3SDag-Erling Smørgrav.Ic -depth
1391c832963SOliver Eikemeierprimary of
1401c832963SOliver Eikemeier.St -p1003.1-2001 .
1411c832963SOliver Eikemeier.Fl d
1421c832963SOliver Eikemeiercan be useful when
1431c832963SOliver Eikemeier.Nm
1441c832963SOliver Eikemeieris used with
1451c832963SOliver Eikemeier.Xr cpio 1
1461c832963SOliver Eikemeierto process files that are contained in directories with unusual permissions.
1471c832963SOliver EikemeierIt ensures that you have write permission while you are placing files in a
1481c832963SOliver Eikemeierdirectory, then sets the directory's permissions as the last thing.
1499b50d902SRodney W. Grimes.It Fl f
1503c94f41fSPhilippe CharnierSpecify a file hierarchy for
1518fe908efSRuslan Ermilov.Nm
1529b50d902SRodney W. Grimesto traverse.
1539b50d902SRodney W. GrimesFile hierarchies may also be specified as the operands immediately
1549b50d902SRodney W. Grimesfollowing the options.
1556d0c7e13SWolfram Schneider.It Fl s
1563c94f41fSPhilippe CharnierCause
1578fe908efSRuslan Ermilov.Nm
1586df69548SBruce Evansto traverse the file hierarchies in lexicographical order,
1596df69548SBruce Evansi.e., alphabetical order within each directory.
1606df69548SBruce EvansNote:
161bfd12208SRuslan Ermilov.Ql find -s
1626d0c7e13SWolfram Schneiderand
163bfd12208SRuslan Ermilov.Ql "find | sort"
1646d0c7e13SWolfram Schneidermay give different results.
1659b50d902SRodney W. Grimes.It Fl x
1663c94f41fSPhilippe CharnierPrevent
1678fe908efSRuslan Ermilov.Nm
1689b50d902SRodney W. Grimesfrom descending into directories that have a device number different
1699b50d902SRodney W. Grimesthan that of the file from which the descent began.
17047d91ba3SDag-Erling Smørgrav.Pp
17147d91ba3SDag-Erling SmørgravThis option is equivalent to the deprecated
17247d91ba3SDag-Erling Smørgrav.Ic -xdev
17347d91ba3SDag-Erling Smørgravprimary.
1749b50d902SRodney W. Grimes.El
1759b50d902SRodney W. Grimes.Sh PRIMARIES
176bfd12208SRuslan Ermilov.Bl -tag -width indent
17753e87059STom Rhodes.It Ic -acl
17853e87059STom RhodesMay be used in conjunction with other options to locate
17953e87059STom Rhodesfiles with extended ACLs.
18053e87059STom RhodesSee
18153e87059STom Rhodes.Xr acl 3
18253e87059STom Rhodesfor more information.
1833f5223f8SWolfram Schneider.It Ic -amin Ar n
1843f5223f8SWolfram SchneiderTrue if the difference between the file last access time and the time
1858fe908efSRuslan Ermilov.Nm
18645fe9882SMatthew Huntwas started, rounded up to the next full minute, is
1873f5223f8SWolfram Schneider.Ar n
18845fe9882SMatthew Huntminutes.
189ea92232aSPoul-Henning Kamp.It Ic -anewer Ar file
190ea92232aSPoul-Henning KampSame as
191ea92232aSPoul-Henning Kamp.Ic -neweram .
192adff4fcaSRuslan Ermilov.It Ic -atime Ar n Ns Op Cm smhdw
193adff4fcaSRuslan ErmilovIf no units are specified, this primary evaluates to
194adff4fcaSRuslan Ermilovtrue if the difference between the file last access time and the time
1958fe908efSRuslan Ermilov.Nm
19654874bb6SRuslan Ermilovwas started, rounded up to the next full 24-hour period, is
1979b50d902SRodney W. Grimes.Ar n
19854874bb6SRuslan Ermilov24-hour periods.
199adff4fcaSRuslan Ermilov.Pp
200adff4fcaSRuslan ErmilovIf units are specified, this primary evaluates to
201adff4fcaSRuslan Ermilovtrue if the difference between the file last access time and the time
202adff4fcaSRuslan Ermilov.Nm
203adff4fcaSRuslan Ermilovwas started is exactly
204adff4fcaSRuslan Ermilov.Ar n
205adff4fcaSRuslan Ermilovunits.
206adff4fcaSRuslan ErmilovPossible time units are as follows:
207adff4fcaSRuslan Ermilov.Pp
208adff4fcaSRuslan Ermilov.Bl -tag -width indent -compact
209adff4fcaSRuslan Ermilov.It Cm s
210adff4fcaSRuslan Ermilovsecond
211adff4fcaSRuslan Ermilov.It Cm m
212adff4fcaSRuslan Ermilovminute (60 seconds)
213adff4fcaSRuslan Ermilov.It Cm h
214adff4fcaSRuslan Ermilovhour (60 minutes)
215adff4fcaSRuslan Ermilov.It Cm d
216adff4fcaSRuslan Ermilovday (24 hours)
217adff4fcaSRuslan Ermilov.It Cm w
218adff4fcaSRuslan Ermilovweek (7 days)
219adff4fcaSRuslan Ermilov.El
220adff4fcaSRuslan Ermilov.Pp
221adff4fcaSRuslan ErmilovAny number of units may be combined in one
222adff4fcaSRuslan Ermilov.Ic -atime
223adff4fcaSRuslan Ermilovargument, for example,
224adff4fcaSRuslan Ermilov.Dq Li "-atime -1h30m" .
225adff4fcaSRuslan ErmilovUnits are probably only useful when used in conjunction with the
226adff4fcaSRuslan Ermilov.Cm +
227adff4fcaSRuslan Ermilovor
228adff4fcaSRuslan Ermilov.Cm -
229adff4fcaSRuslan Ermilovmodifier.
2303f5223f8SWolfram Schneider.It Ic -cmin Ar n
2313f5223f8SWolfram SchneiderTrue if the difference between the time of last change of file status
2323f5223f8SWolfram Schneiderinformation and the time
2338fe908efSRuslan Ermilov.Nm
23445fe9882SMatthew Huntwas started, rounded up to the next full minute, is
2353f5223f8SWolfram Schneider.Ar n
23645fe9882SMatthew Huntminutes.
237ea92232aSPoul-Henning Kamp.It Ic -cnewer Ar file
238ea92232aSPoul-Henning KampSame as
239ea92232aSPoul-Henning Kamp.Ic -newercm .
240adff4fcaSRuslan Ermilov.It Ic -ctime Ar n Ns Op Cm smhdw
241adff4fcaSRuslan ErmilovIf no units are specified, this primary evaluates to
242adff4fcaSRuslan Ermilovtrue if the difference between the time of last change of file status
2439b50d902SRodney W. Grimesinformation and the time
2448fe908efSRuslan Ermilov.Nm
24554874bb6SRuslan Ermilovwas started, rounded up to the next full 24-hour period, is
2469b50d902SRodney W. Grimes.Ar n
24754874bb6SRuslan Ermilov24-hour periods.
248adff4fcaSRuslan Ermilov.Pp
249adff4fcaSRuslan ErmilovIf units are specified, this primary evaluates to
250adff4fcaSRuslan Ermilovtrue if the difference between the time of last change of file status
251adff4fcaSRuslan Ermilovinformation and the time
252adff4fcaSRuslan Ermilov.Nm
253adff4fcaSRuslan Ermilovwas started is exactly
254adff4fcaSRuslan Ermilov.Ar n
255adff4fcaSRuslan Ermilovunits.
256adff4fcaSRuslan ErmilovPlease refer to the
257adff4fcaSRuslan Ermilov.Ic -atime
258adff4fcaSRuslan Ermilovprimary description for information on supported time units.
259abacbbbfSPeter Wemm.It Ic -delete
2606df69548SBruce EvansDelete found files and/or directories.
2616df69548SBruce EvansAlways returns true.
2626df69548SBruce EvansThis executes
263abacbbbfSPeter Wemmfrom the current working directory as
264abacbbbfSPeter Wemm.Nm
2656df69548SBruce Evansrecurses down the tree.
266bfd12208SRuslan ErmilovIt will not attempt to delete a filename with a
267bfd12208SRuslan Ermilov.Dq Pa /
268bfd12208SRuslan Ermilovcharacter in its pathname relative to
269bfd12208SRuslan Ermilov.Dq Pa \&.
270bfd12208SRuslan Ermilovfor security reasons.
27154874bb6SRuslan ErmilovDepth-first traversal processing is implied by this option.
2729b4e871aSDavid E. O'Brien.It Ic -depth
2739b4e871aSDavid E. O'BrienAlways true;
2749b4e871aSDavid E. O'Briensame as the
2759b4e871aSDavid E. O'Brien.Fl d
2769b4e871aSDavid E. O'Brienoption.
2771c832963SOliver Eikemeier.It Ic -depth Ar n
2781c832963SOliver EikemeierTrue if the depth of the file relative to the starting point of the traversal
2791c832963SOliver Eikemeieris
2801c832963SOliver Eikemeier.Ar n .
281ed1a4621SPeter Wemm.It Ic -empty
282ed1a4621SPeter WemmTrue if the current file or directory is empty.
283c93e83feSRuslan Ermilov.It Ic -exec Ar utility Oo Ar argument ... Oc Li \&;
2849b50d902SRodney W. GrimesTrue if the program named
2859b50d902SRodney W. Grimes.Ar utility
2869b50d902SRodney W. Grimesreturns a zero value as its exit status.
287bfd12208SRuslan ErmilovOptional
288bfd12208SRuslan Ermilov.Ar arguments
289bfd12208SRuslan Ermilovmay be passed to the utility.
290bfd12208SRuslan ErmilovThe expression must be terminated by a semicolon
291bfd12208SRuslan Ermilov.Pq Dq Li \&; .
2926a2b59f8SJens SchweikhardtIf you invoke
2936a2b59f8SJens Schweikhardt.Nm
2946a2b59f8SJens Schweikhardtfrom a shell you may need to quote the semicolon if the shell would
2956a2b59f8SJens Schweikhardtotherwise treat it as a control operator.
296bfd12208SRuslan ErmilovIf the string
297bfd12208SRuslan Ermilov.Dq Li {}
298bfd12208SRuslan Ermilovappears anywhere in the utility name or the
2999b50d902SRodney W. Grimesarguments it is replaced by the pathname of the current file.
3009b50d902SRodney W. Grimes.Ar Utility
3019b50d902SRodney W. Grimeswill be executed from the directory from which
3028fe908efSRuslan Ermilov.Nm
3039b50d902SRodney W. Grimeswas executed.
30408274979SYaroslav Tykhiy.Ar Utility
30508274979SYaroslav Tykhiyand
30608274979SYaroslav Tykhiy.Ar arguments
30708274979SYaroslav Tykhiyare not subject to the further expansion of shell patterns
30808274979SYaroslav Tykhiyand constructs.
309c93e83feSRuslan Ermilov.It Ic -exec Ar utility Oo Ar argument ... Oc Li {} +
3105e25d888STim J. RobbinsSame as
3115e25d888STim J. Robbins.Ic -exec ,
3125e25d888STim J. Robbinsexcept that
3135e25d888STim J. Robbins.Dq Li {}
3145e25d888STim J. Robbinsis replaced with as many pathnames as possible for each invocation of
3155e25d888STim J. Robbins.Ar utility .
3165e25d888STim J. RobbinsThis behaviour is similar to that of
3175e25d888STim J. Robbins.Xr xargs 1 .
318c93e83feSRuslan Ermilov.It Ic -execdir Ar utility Oo Ar argument ... Oc Li \&;
319127d7563SWarner LoshThe
320bfd12208SRuslan Ermilov.Ic -execdir
321127d7563SWarner Loshprimary is identical to the
322127d7563SWarner Losh.Ic -exec
323127d7563SWarner Loshprimary with the exception that
324bfd12208SRuslan Ermilov.Ar utility
325127d7563SWarner Loshwill be executed from the directory that holds
3266df69548SBruce Evansthe current file.
3276df69548SBruce EvansThe filename substituted for
328bfd12208SRuslan Ermilovthe string
329bfd12208SRuslan Ermilov.Dq Li {}
330bfd12208SRuslan Ermilovis not qualified.
3317fd5ee41SRuslan Ermilov.It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags
3327fd5ee41SRuslan ErmilovThe flags are specified using symbolic names (see
333208691fcSRuslan Ermilov.Xr chflags 1 ) .
3347fd5ee41SRuslan ErmilovThose with the
3357fd5ee41SRuslan Ermilov.Qq Li no
3367fd5ee41SRuslan Ermilovprefix (except
3377fd5ee41SRuslan Ermilov.Qq Li nodump )
3387fd5ee41SRuslan Ermilovare said to be
3397fd5ee41SRuslan Ermilov.Ar notflags .
3407fd5ee41SRuslan ErmilovFlags in
3417fd5ee41SRuslan Ermilov.Ar flags
3427fd5ee41SRuslan Ermilovare checked to be set, and flags in
3437fd5ee41SRuslan Ermilov.Ar notflags
3447fd5ee41SRuslan Ermilovare checked to be not set.
345208691fcSRuslan ErmilovNote that this is different from
346208691fcSRuslan Ermilov.Ic -perm ,
3477fd5ee41SRuslan Ermilovwhich only allows the user to specify mode bits that are set.
3487fd5ee41SRuslan Ermilov.Pp
3497fd5ee41SRuslan ErmilovIf flags are preceded by a dash
3507fd5ee41SRuslan Ermilov.Pq Dq Li - ,
3517fd5ee41SRuslan Ermilovthis primary evaluates to true
3527fd5ee41SRuslan Ermilovif at least all of the bits in
3537fd5ee41SRuslan Ermilov.Ar flags
3547fd5ee41SRuslan Ermilovand none of the bits in
3557fd5ee41SRuslan Ermilov.Ar notflags
3567fd5ee41SRuslan Ermilovare set in the file's flags bits.
3577fd5ee41SRuslan ErmilovIf flags are preceded by a plus
3587fd5ee41SRuslan Ermilov.Pq Dq Li + ,
3597fd5ee41SRuslan Ermilovthis primary evaluates to true
3607fd5ee41SRuslan Ermilovif any of the bits in
3617fd5ee41SRuslan Ermilov.Ar flags
3627fd5ee41SRuslan Ermilovis set in the file's flags bits,
3637fd5ee41SRuslan Ermilovor any of the bits in
3647fd5ee41SRuslan Ermilov.Ar notflags
3657fd5ee41SRuslan Ermilovis not set in the file's flags bits.
3667fd5ee41SRuslan ErmilovOtherwise,
3677fd5ee41SRuslan Ermilovthis primary evaluates to true
3687fd5ee41SRuslan Ermilovif the bits in
3697fd5ee41SRuslan Ermilov.Ar flags
3707fd5ee41SRuslan Ermilovexactly match the file's flags bits,
3717fd5ee41SRuslan Ermilovand none of the
3727fd5ee41SRuslan Ermilov.Ar flags
3737fd5ee41SRuslan Ermilovbits match those of
3747fd5ee41SRuslan Ermilov.Ar notflags .
3759b50d902SRodney W. Grimes.It Ic -fstype Ar type
3769b50d902SRodney W. GrimesTrue if the file is contained in a file system of type
3779b50d902SRodney W. Grimes.Ar type .
378841484cdSPeter WemmThe
379841484cdSPeter Wemm.Xr sysctl 8
380841484cdSPeter Wemmcommand can be used to find out the types of file systems
381841484cdSPeter Wemmthat are available on the system:
382bfd12208SRuslan Ermilov.Pp
383bfd12208SRuslan Ermilov.Dl "sysctl vfs"
384bfd12208SRuslan Ermilov.Pp
385bfd12208SRuslan ErmilovIn addition, there are two pseudo-types,
386bfd12208SRuslan Ermilov.Dq Li local
387bfd12208SRuslan Ermilovand
388bfd12208SRuslan Ermilov.Dq Li rdonly .
3899b50d902SRodney W. GrimesThe former matches any file system physically mounted on the system where
3909b50d902SRodney W. Grimesthe
3918fe908efSRuslan Ermilov.Nm
3929b50d902SRodney W. Grimesis being executed and the latter matches any file system which is
3939b50d902SRodney W. Grimesmounted read-only.
3949b50d902SRodney W. Grimes.It Ic -group Ar gname
3959b50d902SRodney W. GrimesTrue if the file belongs to the group
3969b50d902SRodney W. Grimes.Ar gname .
3979b50d902SRodney W. GrimesIf
3989b50d902SRodney W. Grimes.Ar gname
3999b50d902SRodney W. Grimesis numeric and there is no such group name, then
4009b50d902SRodney W. Grimes.Ar gname
401bfd12208SRuslan Ermilovis treated as a group ID.
402208691fcSRuslan Ermilov.It Ic -iname Ar pattern
403208691fcSRuslan ErmilovLike
404208691fcSRuslan Ermilov.Ic -name ,
405208691fcSRuslan Ermilovbut the match is case insensitive.
4069b50d902SRodney W. Grimes.It Ic -inum Ar n
4079b50d902SRodney W. GrimesTrue if the file has inode number
4089b50d902SRodney W. Grimes.Ar n .
409208691fcSRuslan Ermilov.It Ic -ipath Ar pattern
410208691fcSRuslan ErmilovLike
411208691fcSRuslan Ermilov.Ic -path ,
412208691fcSRuslan Ermilovbut the match is case insensitive.
413208691fcSRuslan Ermilov.It Ic -iregex Ar pattern
414208691fcSRuslan ErmilovLike
415208691fcSRuslan Ermilov.Ic -regex ,
416208691fcSRuslan Ermilovbut the match is case insensitive.
4179b50d902SRodney W. Grimes.It Ic -links Ar n
4189b50d902SRodney W. GrimesTrue if the file has
4199b50d902SRodney W. Grimes.Ar n
4209b50d902SRodney W. Grimeslinks.
4219b50d902SRodney W. Grimes.It Ic -ls
4229b50d902SRodney W. GrimesThis primary always evaluates to true.
4239b50d902SRodney W. GrimesThe following information for the current file is written to standard output:
42454874bb6SRuslan Ermilovits inode number, size in 512-byte blocks, file permissions, number of hard
4259b50d902SRodney W. Grimeslinks, owner, group, size in bytes, last modification time, and pathname.
4269b50d902SRodney W. GrimesIf the file is a block or character special file, the major and minor numbers
4279b50d902SRodney W. Grimeswill be displayed instead of the size in bytes.
42854874bb6SRuslan ErmilovIf the file is a symbolic link, the pathname of the linked-to file will be
429bfd12208SRuslan Ermilovdisplayed preceded by
430bfd12208SRuslan Ermilov.Dq Li -> .
431bfd12208SRuslan ErmilovThe format is identical to that produced by
432bfd12208SRuslan Ermilov.Bk -words
433bfd12208SRuslan Ermilov.Nm ls Fl dgils .
434bfd12208SRuslan Ermilov.Ek
435c76bc8f3SOllivier Robert.It Ic -maxdepth Ar n
4369c61111dSOliver EikemeierAlways true; descend at most
4379c61111dSOliver Eikemeier.Ar n
4389c61111dSOliver Eikemeierdirectory levels below the command line arguments.
439d79829afSOliver EikemeierIf any
440d79829afSOliver Eikemeier.Ic -maxdepth
441d79829afSOliver Eikemeierprimary is specified, it applies to the entire expression even if it would
442d79829afSOliver Eikemeiernot normally be evaluated.
443d79829afSOliver Eikemeier.Ic -maxdepth Li 0
444d79829afSOliver Eikemeierlimits the whole search to the command line arguments.
445c76bc8f3SOllivier Robert.It Ic -mindepth Ar n
4469c61111dSOliver EikemeierAlways true; do not apply any tests or actions at levels less than
4479c61111dSOliver Eikemeier.Ar n .
448d79829afSOliver EikemeierIf any
449d79829afSOliver Eikemeier.Ic -mindepth
450d79829afSOliver Eikemeierprimary is specified, it applies to the entire expression even if it would
451d79829afSOliver Eikemeiernot normally be evaluated.
452d79829afSOliver Eikemeier.Ic -mindepth Li 1
453d79829afSOliver Eikemeierprocesses all but the command line arguments.
4543f5223f8SWolfram Schneider.It Ic -mmin Ar n
4553f5223f8SWolfram SchneiderTrue if the difference between the file last modification time and the time
4568fe908efSRuslan Ermilov.Nm
45745fe9882SMatthew Huntwas started, rounded up to the next full minute, is
4583f5223f8SWolfram Schneider.Ar n
45945fe9882SMatthew Huntminutes.
460208691fcSRuslan Ermilov.It Ic -mnewer Ar file
461208691fcSRuslan ErmilovSame as
462208691fcSRuslan Ermilov.Ic -newer .
463adff4fcaSRuslan Ermilov.It Ic -mtime Ar n Ns Op Cm smhdw
464adff4fcaSRuslan ErmilovIf no units are specified, this primary evaluates to
465adff4fcaSRuslan Ermilovtrue if the difference between the file last modification time and the time
4668fe908efSRuslan Ermilov.Nm
46754874bb6SRuslan Ermilovwas started, rounded up to the next full 24-hour period, is
4689b50d902SRodney W. Grimes.Ar n
46954874bb6SRuslan Ermilov24-hour periods.
470adff4fcaSRuslan Ermilov.Pp
471adff4fcaSRuslan ErmilovIf units are specified, this primary evaluates to
472adff4fcaSRuslan Ermilovtrue if the difference between the file last modification time and the time
473adff4fcaSRuslan Ermilov.Nm
474adff4fcaSRuslan Ermilovwas started is exactly
475adff4fcaSRuslan Ermilov.Ar n
476adff4fcaSRuslan Ermilovunits.
477adff4fcaSRuslan ErmilovPlease refer to the
478adff4fcaSRuslan Ermilov.Ic -atime
479adff4fcaSRuslan Ermilovprimary description for information on supported time units.
4809b50d902SRodney W. Grimes.It Ic -name Ar pattern
4819b50d902SRodney W. GrimesTrue if the last component of the pathname being examined matches
4829b50d902SRodney W. Grimes.Ar pattern .
483bfd12208SRuslan ErmilovSpecial shell pattern matching characters
484bfd12208SRuslan Ermilov.Dq ( Li \&[ ,
485bfd12208SRuslan Ermilov.Dq Li \&] ,
486bfd12208SRuslan Ermilov.Dq Li * ,
487bfd12208SRuslan Ermilovand
488bfd12208SRuslan Ermilov.Dq Li \&? )
4899b50d902SRodney W. Grimesmay be used as part of
4909b50d902SRodney W. Grimes.Ar pattern .
4919b50d902SRodney W. GrimesThese characters may be matched explicitly by escaping them with a
492bfd12208SRuslan Ermilovbackslash
493bfd12208SRuslan Ermilov.Pq Dq Li \e .
4949b50d902SRodney W. Grimes.It Ic -newer Ar file
4959b50d902SRodney W. GrimesTrue if the current file has a more recent last modification time than
4969b50d902SRodney W. Grimes.Ar file .
497bfd12208SRuslan Ermilov.It Ic -newer Ns Ar X Ns Ar Y Ar file
498bfd12208SRuslan ErmilovTrue if the current file has a more recent last access time
499bfd12208SRuslan Ermilov.Ar ( X Ns = Ns Cm a ) ,
500bfd12208SRuslan Ermilovchange time
501bfd12208SRuslan Ermilov.Ar ( X Ns = Ns Cm c ) ,
502bfd12208SRuslan Ermilovor modification time
503bfd12208SRuslan Ermilov.Ar ( X Ns = Ns Cm m )
504bfd12208SRuslan Ermilovthan the last access time
505bfd12208SRuslan Ermilov.Ar ( Y Ns = Ns Cm a ) ,
506bfd12208SRuslan Ermilovchange time
507bfd12208SRuslan Ermilov.Ar ( Y Ns = Ns Cm c ) ,
508bfd12208SRuslan Ermilovor modification time
509bfd12208SRuslan Ermilov.Ar ( Y Ns = Ns Cm m )
510bfd12208SRuslan Ermilovof
511ea92232aSPoul-Henning Kamp.Ar file .
512ea92232aSPoul-Henning KampIn addition, if
513bfd12208SRuslan Ermilov.Ar Y Ns = Ns Cm t ,
514ea92232aSPoul-Henning Kampthen
515ea92232aSPoul-Henning Kamp.Ar file
516ea92232aSPoul-Henning Kampis instead interpreted as a direct date specification of the form
517ea92232aSPoul-Henning Kampunderstood by
518ea92232aSPoul-Henning Kamp.Xr cvs 1 .
519ea92232aSPoul-Henning KampNote that
520ea92232aSPoul-Henning Kamp.Ic -newermm
521ea92232aSPoul-Henning Kampis equivalent to
522ea92232aSPoul-Henning Kamp.Ic -newer .
5239b50d902SRodney W. Grimes.It Ic -nogroup
5249b50d902SRodney W. GrimesTrue if the file belongs to an unknown group.
525208691fcSRuslan Ermilov.It Ic -nouser
526208691fcSRuslan ErmilovTrue if the file belongs to an unknown user.
527c93e83feSRuslan Ermilov.It Ic -ok Ar utility Oo Ar argument ... Oc Li \&;
528208691fcSRuslan ErmilovThe
529208691fcSRuslan Ermilov.Ic -ok
530208691fcSRuslan Ermilovprimary is identical to the
531208691fcSRuslan Ermilov.Ic -exec
532208691fcSRuslan Ermilovprimary with the exception that
533208691fcSRuslan Ermilov.Nm
534208691fcSRuslan Ermilovrequests user affirmation for the execution of the
535208691fcSRuslan Ermilov.Ar utility
536208691fcSRuslan Ermilovby printing
537208691fcSRuslan Ermilova message to the terminal and reading a response.
538208691fcSRuslan ErmilovIf the response is other than
539208691fcSRuslan Ermilov.Dq Li y
540208691fcSRuslan Ermilovthe command is not executed and the
541208691fcSRuslan Ermilovvalue of the
542208691fcSRuslan Ermilov.Ic -ok
543208691fcSRuslan Ermilovexpression is false.
544c93e83feSRuslan Ermilov.It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&;
545208691fcSRuslan ErmilovThe
546208691fcSRuslan Ermilov.Ic -okdir
547208691fcSRuslan Ermilovprimary is identical to the
548208691fcSRuslan Ermilov.Ic -execdir
549208691fcSRuslan Ermilovprimary with the same exception as described for the
550208691fcSRuslan Ermilov.Ic -ok
551208691fcSRuslan Ermilovprimary.
5529b50d902SRodney W. Grimes.It Ic -path Ar pattern
5539b50d902SRodney W. GrimesTrue if the pathname being examined matches
5549b50d902SRodney W. Grimes.Ar pattern .
555bfd12208SRuslan ErmilovSpecial shell pattern matching characters
556bfd12208SRuslan Ermilov.Dq ( Li \&[ ,
557bfd12208SRuslan Ermilov.Dq Li \&] ,
558bfd12208SRuslan Ermilov.Dq Li * ,
559bfd12208SRuslan Ermilovand
560bfd12208SRuslan Ermilov.Dq Li \&? )
5619b50d902SRodney W. Grimesmay be used as part of
5629b50d902SRodney W. Grimes.Ar pattern .
5639b50d902SRodney W. GrimesThese characters may be matched explicitly by escaping them with a
564bfd12208SRuslan Ermilovbackslash
565bfd12208SRuslan Ermilov.Pq Dq Li \e .
566bfd12208SRuslan ErmilovSlashes
567bfd12208SRuslan Ermilov.Pq Dq Li /
568bfd12208SRuslan Ermilovare treated as normal characters and do not have to be
5699b50d902SRodney W. Grimesmatched explicitly.
5707fd5ee41SRuslan Ermilov.It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode
5719b50d902SRodney W. GrimesThe
5729b50d902SRodney W. Grimes.Ar mode
5739b50d902SRodney W. Grimesmay be either symbolic (see
5749b50d902SRodney W. Grimes.Xr chmod 1 )
5759b50d902SRodney W. Grimesor an octal number.
5767fd5ee41SRuslan ErmilovIf the
5777fd5ee41SRuslan Ermilov.Ar mode
5787fd5ee41SRuslan Ermilovis symbolic, a starting value of zero is assumed and the
5797fd5ee41SRuslan Ermilov.Ar mode
5807fd5ee41SRuslan Ermilovsets or clears permissions without regard to the process' file mode
5819b50d902SRodney W. Grimescreation mask.
5827fd5ee41SRuslan ErmilovIf the
5837fd5ee41SRuslan Ermilov.Ar mode
5847fd5ee41SRuslan Ermilovis octal, only bits 07777
585bfd12208SRuslan Ermilov.Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
5869b50d902SRodney W. Grimesof the file's mode bits participate
5879b50d902SRodney W. Grimesin the comparison.
5887fd5ee41SRuslan ErmilovIf the
5897fd5ee41SRuslan Ermilov.Ar mode
5907fd5ee41SRuslan Ermilovis preceded by a dash
591bfd12208SRuslan Ermilov.Pq Dq Li - ,
5929b88faecSRuslan Ermilovthis primary evaluates to true
5937fd5ee41SRuslan Ermilovif at least all of the bits in the
5947fd5ee41SRuslan Ermilov.Ar mode
5957fd5ee41SRuslan Ermilovare set in the file's mode bits.
5967fd5ee41SRuslan ErmilovIf the
5977fd5ee41SRuslan Ermilov.Ar mode
5987fd5ee41SRuslan Ermilovis preceded by a plus
599bfd12208SRuslan Ermilov.Pq Dq Li + ,
6009b88faecSRuslan Ermilovthis primary evaluates to true
6017fd5ee41SRuslan Ermilovif any of the bits in the
6027fd5ee41SRuslan Ermilov.Ar mode
6037fd5ee41SRuslan Ermilovare set in the file's mode bits.
6049d2796c3SOllivier RobertOtherwise, this primary evaluates to true if
6057fd5ee41SRuslan Ermilovthe bits in the
6067fd5ee41SRuslan Ermilov.Ar mode
6077fd5ee41SRuslan Ermilovexactly match the file's mode bits.
608bfd12208SRuslan ErmilovNote, the first character of a symbolic mode may not be a dash
609bfd12208SRuslan Ermilov.Pq Dq Li - .
6109b50d902SRodney W. Grimes.It Ic -print
6119b50d902SRodney W. GrimesThis primary always evaluates to true.
6129b50d902SRodney W. GrimesIt prints the pathname of the current file to standard output.
613841484cdSPeter WemmIf none of
614bfd12208SRuslan Ermilov.Ic -exec , -ls , -print0 ,
6159b50d902SRodney W. Grimesor
616bfd12208SRuslan Ermilov.Ic -ok
617841484cdSPeter Wemmis specified, the given expression shall be effectively replaced by
618bfd12208SRuslan Ermilov.Cm \&( Ar "given expression" Cm \&) Ic -print .
6197cd23434SGarrett Wollman.It Ic -print0
6207cd23434SGarrett WollmanThis primary always evaluates to true.
621fbe0d04aSMasafumi Max NAKANEIt prints the pathname of the current file to standard output, followed by an
622bfd12208SRuslan Ermilov.Tn ASCII NUL
6237cd23434SGarrett Wollmancharacter (character code 0).
6249b50d902SRodney W. Grimes.It Ic -prune
6259b50d902SRodney W. GrimesThis primary always evaluates to true.
6269b50d902SRodney W. GrimesIt causes
6278fe908efSRuslan Ermilov.Nm
6289b50d902SRodney W. Grimesto not descend into the current file.
6299b50d902SRodney W. GrimesNote, the
6309b50d902SRodney W. Grimes.Ic -prune
6319b50d902SRodney W. Grimesprimary has no effect if the
6329b50d902SRodney W. Grimes.Fl d
6339b50d902SRodney W. Grimesoption was specified.
634208691fcSRuslan Ermilov.It Ic -regex Ar pattern
635208691fcSRuslan ErmilovTrue if the whole path of the file matches
636208691fcSRuslan Ermilov.Ar pattern
637208691fcSRuslan Ermilovusing regular expression.
638208691fcSRuslan ErmilovTo match a file named
639208691fcSRuslan Ermilov.Dq Pa ./foo/xyzzy ,
640208691fcSRuslan Ermilovyou can use the regular expression
641208691fcSRuslan Ermilov.Dq Li ".*/[xyz]*"
642208691fcSRuslan Ermilovor
643208691fcSRuslan Ermilov.Dq Li ".*/foo/.*" ,
644208691fcSRuslan Ermilovbut not
645208691fcSRuslan Ermilov.Dq Li xyzzy
646208691fcSRuslan Ermilovor
647208691fcSRuslan Ermilov.Dq Li /foo/ .
6489b50d902SRodney W. Grimes.It Ic -size Ar n Ns Op Cm c
64954874bb6SRuslan ErmilovTrue if the file's size, rounded up, in 512-byte blocks is
6509b50d902SRodney W. Grimes.Ar n .
6519b50d902SRodney W. GrimesIf
6529b50d902SRodney W. Grimes.Ar n
653bfd12208SRuslan Ermilovis followed by a
654bfd12208SRuslan Ermilov.Cm c ,
655bfd12208SRuslan Ermilovthen the primary is true if the
6569b50d902SRodney W. Grimesfile's size is
6579b50d902SRodney W. Grimes.Ar n
658bfd12208SRuslan Ermilovbytes (characters).
6599b50d902SRodney W. Grimes.It Ic -type Ar t
6609b50d902SRodney W. GrimesTrue if the file is of the specified type.
6619b50d902SRodney W. GrimesPossible file types are as follows:
6629b50d902SRodney W. Grimes.Pp
663bfd12208SRuslan Ermilov.Bl -tag -width indent -compact
6649b50d902SRodney W. Grimes.It Cm b
6659b50d902SRodney W. Grimesblock special
6669b50d902SRodney W. Grimes.It Cm c
6679b50d902SRodney W. Grimescharacter special
6689b50d902SRodney W. Grimes.It Cm d
6699b50d902SRodney W. Grimesdirectory
6709b50d902SRodney W. Grimes.It Cm f
6719b50d902SRodney W. Grimesregular file
6729b50d902SRodney W. Grimes.It Cm l
6739b50d902SRodney W. Grimessymbolic link
6749b50d902SRodney W. Grimes.It Cm p
6759b50d902SRodney W. GrimesFIFO
6769b50d902SRodney W. Grimes.It Cm s
6779b50d902SRodney W. Grimessocket
6789b50d902SRodney W. Grimes.El
6799b50d902SRodney W. Grimes.It Ic -user Ar uname
6809b50d902SRodney W. GrimesTrue if the file belongs to the user
6819b50d902SRodney W. Grimes.Ar uname .
6829b50d902SRodney W. GrimesIf
6839b50d902SRodney W. Grimes.Ar uname
6849b50d902SRodney W. Grimesis numeric and there is no such user name, then
6859b50d902SRodney W. Grimes.Ar uname
686bfd12208SRuslan Ermilovis treated as a user ID.
6879b50d902SRodney W. Grimes.El
6889b50d902SRodney W. Grimes.Pp
6899b50d902SRodney W. GrimesAll primaries which take a numeric argument allow the number to be
6909b88faecSRuslan Ermilovpreceded by a plus sign
691bfd12208SRuslan Ermilov.Pq Dq Li +
6929b88faecSRuslan Ermilovor a minus sign
693bfd12208SRuslan Ermilov.Pq Dq Li - .
694bfd12208SRuslan ErmilovA preceding plus sign means
695bfd12208SRuslan Ermilov.Dq more than n ,
696bfd12208SRuslan Ermilova preceding minus sign means
697bfd12208SRuslan Ermilov.Dq less than n
698bfd12208SRuslan Ermilovand neither means
699bfd12208SRuslan Ermilov.Dq exactly n .
7009b50d902SRodney W. Grimes.Sh OPERATORS
7019b50d902SRodney W. GrimesThe primaries may be combined using the following operators.
7029b50d902SRodney W. GrimesThe operators are listed in order of decreasing precedence.
703bfd12208SRuslan Ermilov.Pp
704bfd12208SRuslan Ermilov.Bl -tag -width "( expression )" -compact
7050c101fb2SJoseph Koshy.It Cm \&( Ar expression Cm \&)
7069b50d902SRodney W. GrimesThis evaluates to true if the parenthesized expression evaluates to
7079b50d902SRodney W. Grimestrue.
7089b50d902SRodney W. Grimes.Pp
7090c101fb2SJoseph Koshy.It Cm \&! Ar expression
710c9776a93SJuli Mallett.It Cm -false Ar expression
7114a0193d3SJuli Mallett.It Cm -not Ar expression
7129b50d902SRodney W. GrimesThis is the unary
7139b50d902SRodney W. Grimes.Tn NOT
7149b50d902SRodney W. Grimesoperator.
7159b50d902SRodney W. GrimesIt evaluates to true if the expression is false.
7169b50d902SRodney W. Grimes.Pp
7179b50d902SRodney W. Grimes.It Ar expression Cm -and Ar expression
7189b50d902SRodney W. Grimes.It Ar expression expression
7199b50d902SRodney W. GrimesThe
7209b50d902SRodney W. Grimes.Cm -and
7219b50d902SRodney W. Grimesoperator is the logical
7229b50d902SRodney W. Grimes.Tn AND
7239b50d902SRodney W. Grimesoperator.
7249b50d902SRodney W. GrimesAs it is implied by the juxtaposition of two expressions it does not
7259b50d902SRodney W. Grimeshave to be specified.
7269b50d902SRodney W. GrimesThe expression evaluates to true if both expressions are true.
7279b50d902SRodney W. GrimesThe second expression is not evaluated if the first expression is false.
7289b50d902SRodney W. Grimes.Pp
7299b50d902SRodney W. Grimes.It Ar expression Cm -or Ar expression
7309b50d902SRodney W. GrimesThe
7319b50d902SRodney W. Grimes.Cm -or
7329b50d902SRodney W. Grimesoperator is the logical
7339b50d902SRodney W. Grimes.Tn OR
7349b50d902SRodney W. Grimesoperator.
7359b50d902SRodney W. GrimesThe expression evaluates to true if either the first or the second expression
7369b50d902SRodney W. Grimesis true.
7379b50d902SRodney W. GrimesThe second expression is not evaluated if the first expression is true.
7389b50d902SRodney W. Grimes.El
7399b50d902SRodney W. Grimes.Pp
7409b50d902SRodney W. GrimesAll operands and primaries must be separate arguments to
7418fe908efSRuslan Ermilov.Nm .
7429b50d902SRodney W. GrimesPrimaries which themselves take arguments expect each argument
7439b50d902SRodney W. Grimesto be a separate argument to
7448fe908efSRuslan Ermilov.Nm .
7459b50d902SRodney W. Grimes.Sh EXAMPLES
7469b50d902SRodney W. GrimesThe following examples are shown as given to the shell:
747bfd12208SRuslan Ermilov.Bl -tag -width indent
7489b50d902SRodney W. Grimes.It Li "find / \e! -name \*q*.c\*q -print"
749bfd12208SRuslan ErmilovPrint out a list of all the files whose names do not end in
750bfd12208SRuslan Ermilov.Pa .c .
7519b50d902SRodney W. Grimes.It Li "find / -newer ttt -user wnj -print"
752bfd12208SRuslan ErmilovPrint out a list of all the files owned by user
753bfd12208SRuslan Ermilov.Dq wnj
754bfd12208SRuslan Ermilovthat are newer
755bfd12208SRuslan Ermilovthan the file
756bfd12208SRuslan Ermilov.Pa ttt .
7579b50d902SRodney W. Grimes.It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
758bfd12208SRuslan ErmilovPrint out a list of all the files which are not both newer than
759bfd12208SRuslan Ermilov.Pa ttt
760bfd12208SRuslan Ermilovand owned by
761bfd12208SRuslan Ermilov.Dq wnj .
7629b50d902SRodney W. Grimes.It Li "find / \e( -newer ttt -or -user wnj \e) -print"
763bfd12208SRuslan ErmilovPrint out a list of all the files that are either owned by
764bfd12208SRuslan Ermilov.Dq wnj
765bfd12208SRuslan Ermilovor that are newer than
766bfd12208SRuslan Ermilov.Pa ttt .
767e578c242STom Rhodes.It Li "find / -newerct '1 minute ago' -print"
768ea92232aSPoul-Henning KampPrint out a list of all the files whose inode change time is more
769ea92232aSPoul-Henning Kamprecent than the current time minus one minute.
77054874bb6SRuslan Ermilov.It Li "find / -type f -exec echo {} \e;"
771e578c242STom RhodesUse the
772e578c242STom Rhodes.Xr echo 1
773e578c242STom Rhodescommand to print out a list of all the files.
7741c832963SOliver Eikemeier.It Li "find -L /usr/ports/packages -type l -delete"
7751c832963SOliver EikemeierDelete all broken symbolic links in
7761c832963SOliver Eikemeier.Pa /usr/ports/packages .
7771c832963SOliver Eikemeier.It Li "find /usr/src -name CVS -prune -o -depth +6 -print"
7781c832963SOliver EikemeierFind files and directories that are at least seven levels deep
7791c832963SOliver Eikemeierin the working directory
7801c832963SOliver Eikemeier.Pa /usr/src .
7811c832963SOliver Eikemeier.It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print"
7821c832963SOliver EikemeierIs not equivalent to the previous example, since
7831c832963SOliver Eikemeier.Ic -prune
7841c832963SOliver Eikemeieris not evaluated below level seven.
7859b50d902SRodney W. Grimes.El
786e578c242STom Rhodes.Sh COMPATIBILITY
787e578c242STom RhodesThe
788e578c242STom Rhodes.Ic -follow
78947d91ba3SDag-Erling Smørgravprimary is deprecated; the
79047d91ba3SDag-Erling Smørgrav.Fl L
79147d91ba3SDag-Erling Smørgravoption should be used instead.
79247d91ba3SDag-Erling SmørgravSee the
79347d91ba3SDag-Erling Smørgrav.Sx STANDARDS
79447d91ba3SDag-Erling Smørgravsection below for details.
7959b50d902SRodney W. Grimes.Sh SEE ALSO
796567664c4SOllivier Robert.Xr chflags 1 ,
7979b50d902SRodney W. Grimes.Xr chmod 1 ,
798ea92232aSPoul-Henning Kamp.Xr cvs 1 ,
7999b50d902SRodney W. Grimes.Xr locate 1 ,
80041cbb624SJoseph Koshy.Xr whereis 1 ,
80141cbb624SJoseph Koshy.Xr which 1 ,
802a8d50686STom Rhodes.Xr xargs 1 ,
8039b50d902SRodney W. Grimes.Xr stat 2 ,
80453e87059STom Rhodes.Xr acl 3 ,
8059b50d902SRodney W. Grimes.Xr fts 3 ,
8069b50d902SRodney W. Grimes.Xr getgrent 3 ,
8079b50d902SRodney W. Grimes.Xr getpwent 3 ,
8089b50d902SRodney W. Grimes.Xr strmode 3 ,
80994ad6032SRuslan Ermilov.Xr re_format 7 ,
8109b50d902SRodney W. Grimes.Xr symlink 7
8119b50d902SRodney W. Grimes.Sh STANDARDS
8129b50d902SRodney W. GrimesThe
8138fe908efSRuslan Ermilov.Nm
8149b50d902SRodney W. Grimesutility syntax is a superset of the syntax specified by the
8151c832963SOliver Eikemeier.St -p1003.1-2001
8169b50d902SRodney W. Grimesstandard.
8179b50d902SRodney W. Grimes.Pp
8181c832963SOliver EikemeierAll the single character options except
8191c832963SOliver Eikemeier.Ic -H
8201c832963SOliver Eikemeierand
8211c832963SOliver Eikemeier.Ic -L
8221c832963SOliver Eikemeieras well as the
823bfd12208SRuslan Ermilov.Ic -iname , -inum , -iregex , -print0 , -delete , -ls ,
824f6e4fb22SSteve Priceand
8257c1d4b3aSAkinori MUSHA.Ic -regex
826f6e4fb22SSteve Priceprimaries are extensions to
8271c832963SOliver Eikemeier.St -p1003.1-2001 .
828f6e4fb22SSteve Price.Pp
8299b50d902SRodney W. GrimesHistorically, the
83047d91ba3SDag-Erling Smørgrav.Fl d , L
8319b50d902SRodney W. Grimesand
8329b50d902SRodney W. Grimes.Fl x
833bfd12208SRuslan Ermilovoptions were implemented using the primaries
834bfd12208SRuslan Ermilov.Ic -depth , -follow ,
835bfd12208SRuslan Ermilovand
836bfd12208SRuslan Ermilov.Ic -xdev .
8379b50d902SRodney W. GrimesThese primaries always evaluated to true.
8389b50d902SRodney W. GrimesAs they were really global variables that took effect before the traversal
8399b50d902SRodney W. Grimesbegan, some legal expressions could have unexpected results.
840bfd12208SRuslan ErmilovAn example is the expression
841bfd12208SRuslan Ermilov.Ic -print Cm -o Ic -depth .
842bfd12208SRuslan ErmilovAs
843bfd12208SRuslan Ermilov.Ic -print
844bfd12208SRuslan Ermilovalways evaluates to true, the standard order of evaluation
845bfd12208SRuslan Ermilovimplies that
846bfd12208SRuslan Ermilov.Ic -depth
847bfd12208SRuslan Ermilovwould never be evaluated.
8489b50d902SRodney W. GrimesThis is not the case.
8499b50d902SRodney W. Grimes.Pp
850bfd12208SRuslan ErmilovThe operator
851bfd12208SRuslan Ermilov.Cm -or
852bfd12208SRuslan Ermilovwas implemented as
853bfd12208SRuslan Ermilov.Cm -o ,
854bfd12208SRuslan Ermilovand the operator
855bfd12208SRuslan Ermilov.Cm -and
856bfd12208SRuslan Ermilovwas implemented as
857bfd12208SRuslan Ermilov.Cm -a .
8589b50d902SRodney W. Grimes.Pp
8599b50d902SRodney W. GrimesHistoric implementations of the
860bfd12208SRuslan Ermilov.Ic -exec
8619b50d902SRodney W. Grimesand
862bfd12208SRuslan Ermilov.Ic -ok
863bfd12208SRuslan Ermilovprimaries did not replace the string
864bfd12208SRuslan Ermilov.Dq Li {}
865bfd12208SRuslan Ermilovin the utility name or the
8669b50d902SRodney W. Grimesutility arguments if it had preceding or following non-whitespace characters.
8679b50d902SRodney W. GrimesThis version replaces it no matter where in the utility name or arguments
8689b50d902SRodney W. Grimesit appears.
8697c1d4b3aSAkinori MUSHA.Pp
8707c1d4b3aSAkinori MUSHAThe
8717c1d4b3aSAkinori MUSHA.Fl E
87247d91ba3SDag-Erling Smørgravoption was inspired by the equivalent
8737c1d4b3aSAkinori MUSHA.Xr grep 1
8747c1d4b3aSAkinori MUSHAand
87547d91ba3SDag-Erling Smørgrav.Xr sed 1
87647d91ba3SDag-Erling Smørgravoptions.
877ad487600SColin Percival.Sh HISTORY
878ad487600SColin PercivalA
879ad487600SColin Percival.Nm
880ad487600SColin Percivalcommand appeared in
881ad487600SColin Percival.At v1 .
8829b50d902SRodney W. Grimes.Sh BUGS
8839b50d902SRodney W. GrimesThe special characters used by
8848fe908efSRuslan Ermilov.Nm
8859b50d902SRodney W. Grimesare also special characters to many shell programs.
886bfd12208SRuslan ErmilovIn particular, the characters
887bfd12208SRuslan Ermilov.Dq Li * ,
888bfd12208SRuslan Ermilov.Dq Li \&[ ,
889bfd12208SRuslan Ermilov.Dq Li \&] ,
890bfd12208SRuslan Ermilov.Dq Li \&? ,
891bfd12208SRuslan Ermilov.Dq Li \&( ,
892bfd12208SRuslan Ermilov.Dq Li \&) ,
893bfd12208SRuslan Ermilov.Dq Li \&! ,
894bfd12208SRuslan Ermilov.Dq Li \e
895bfd12208SRuslan Ermilovand
896bfd12208SRuslan Ermilov.Dq Li \&;
897bfd12208SRuslan Ermilovmay have to be escaped from the shell.
8989b50d902SRodney W. Grimes.Pp
8999b50d902SRodney W. GrimesAs there is no delimiter separating options and file names or file
9009b50d902SRodney W. Grimesnames and the
9019b50d902SRodney W. Grimes.Ar expression ,
902bfd12208SRuslan Ermilovit is difficult to specify files named
903bfd12208SRuslan Ermilov.Pa -xdev
904bfd12208SRuslan Ermilovor
905bfd12208SRuslan Ermilov.Pa \&! .
9069b50d902SRodney W. GrimesThese problems are handled by the
9079b50d902SRodney W. Grimes.Fl f
9089b50d902SRodney W. Grimesoption and the
9099b50d902SRodney W. Grimes.Xr getopt 3
910bfd12208SRuslan Ermilov.Dq Fl Fl
911bfd12208SRuslan Ermilovconstruct.
912abacbbbfSPeter Wemm.Pp
913abacbbbfSPeter WemmThe
914abacbbbfSPeter Wemm.Ic -delete
91556f7a840SBill Fumerolaprimary does not interact well with other options that cause the file system
916abacbbbfSPeter Wemmtree traversal options to be changed.
917ad487600SColin Percival.Pp
9184f45d811STim J. RobbinsThe
9194f45d811STim J. Robbins.Nm
9204f45d811STim J. Robbinsutility does not recognize multibyte characters in file names.
921dfef91e9SColin Percival.Pp
922dfef91e9SColin PercivalThe
923dfef91e9SColin Percival.Ic -mindepth
924dfef91e9SColin Percivaland
925dfef91e9SColin Percival.Ic -maxdepth
9262cb640f6SColin Percivalprimaries are actually global options (as documented above).
9272cb640f6SColin PercivalThey should
928dfef91e9SColin Percivalprobably be replaced by options which look like options.
929