Deleted Added
full compact
find.1 (93528) find.1 (94366)
1.\" The Regents of the University of California. All rights reserved.
2.\"
3.\" This code is derived from software contributed to Berkeley by
4.\" the Institute of Electrical and Electronics Engineers, Inc.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)find.1 8.7 (Berkeley) 5/9/95
1.\" The Regents of the University of California. All rights reserved.
2.\"
3.\" This code is derived from software contributed to Berkeley by
4.\" the Institute of Electrical and Electronics Engineers, Inc.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)find.1 8.7 (Berkeley) 5/9/95
35.\" $FreeBSD: head/usr.bin/find/find.1 93528 2002-04-01 12:41:14Z keramida $
35.\" $FreeBSD: head/usr.bin/find/find.1 94366 2002-04-10 16:39:22Z trhodes $
36.\"
37.Dd May 3, 2001
38.Dt FIND 1
39.Os
40.Sh NAME
41.Nm find
42.Nd walk a file hierarchy
43.Sh SYNOPSIS
44.Nm
45.Op Fl H | Fl L | Fl P
46.Op Fl EXdsx
47.Op Fl f Ar pathname
48.Op Ar pathname ...
49.Ar expression
50.Sh DESCRIPTION
51.Nm Find
52recursively descends the directory tree for each
53.Ar pathname
54listed, evaluating an
55.Ar expression
56(composed of the
57.Dq primaries
58and
59.Dq operands
60listed below) in terms
61of each file in the tree.
62.Pp
63The options are as follows:
64.Bl -tag -width indent
65.It Fl E
66Interpret regular expressions followed by
67.Ic -regex
68and
69.Ic -iregex
70options as extended (modern) regular expressions rather than basic
71regular expressions (BRE's).
72The
73.Xr re_format 7
74manual page fully describes both formats.
75.It Fl H
76The
77.Fl H
78option causes the file information and file type (see
79.Xr stat 2 )
80returned for each symbolic link specified on the command line to be
81those of the file referenced by the link, not the link itself.
82If the referenced file does not exist, the file information and type will
83be for the link itself.
84File information of all symbolic links not on
85the command line is that of the link itself.
86.It Fl L
87The
88.Fl L
89option causes the file information and file type (see
90.Xr stat 2 )
91returned for each symbolic link to be those of the file referenced by the
92link, not the link itself.
93If the referenced file does not exist, the file information and type will
94be for the link itself.
95.It Fl P
96The
97.Fl P
98option causes the file information and file type (see
99.Xr stat 2 )
100returned for each symbolic link to be those of the link itself.
101This is the default.
102.It Fl X
103The
104.Fl X
105option is a modification to permit
106.Nm
107to be safely used in conjunction with
108.Xr xargs 1 .
109If a file name contains any of the delimiting characters used by
110.Xr xargs 1 ,
111a diagnostic message is displayed on standard error, and the file
112is skipped.
113The delimiting characters include single
114.Pq Dq Li " ' "
115and double
116.Pq Dq Li " \*q "
117quotes, backslash
118.Pq Dq Li \e ,
119space, tab and newline characters.
36.\"
37.Dd May 3, 2001
38.Dt FIND 1
39.Os
40.Sh NAME
41.Nm find
42.Nd walk a file hierarchy
43.Sh SYNOPSIS
44.Nm
45.Op Fl H | Fl L | Fl P
46.Op Fl EXdsx
47.Op Fl f Ar pathname
48.Op Ar pathname ...
49.Ar expression
50.Sh DESCRIPTION
51.Nm Find
52recursively descends the directory tree for each
53.Ar pathname
54listed, evaluating an
55.Ar expression
56(composed of the
57.Dq primaries
58and
59.Dq operands
60listed below) in terms
61of each file in the tree.
62.Pp
63The options are as follows:
64.Bl -tag -width indent
65.It Fl E
66Interpret regular expressions followed by
67.Ic -regex
68and
69.Ic -iregex
70options as extended (modern) regular expressions rather than basic
71regular expressions (BRE's).
72The
73.Xr re_format 7
74manual page fully describes both formats.
75.It Fl H
76The
77.Fl H
78option causes the file information and file type (see
79.Xr stat 2 )
80returned for each symbolic link specified on the command line to be
81those of the file referenced by the link, not the link itself.
82If the referenced file does not exist, the file information and type will
83be for the link itself.
84File information of all symbolic links not on
85the command line is that of the link itself.
86.It Fl L
87The
88.Fl L
89option causes the file information and file type (see
90.Xr stat 2 )
91returned for each symbolic link to be those of the file referenced by the
92link, not the link itself.
93If the referenced file does not exist, the file information and type will
94be for the link itself.
95.It Fl P
96The
97.Fl P
98option causes the file information and file type (see
99.Xr stat 2 )
100returned for each symbolic link to be those of the link itself.
101This is the default.
102.It Fl X
103The
104.Fl X
105option is a modification to permit
106.Nm
107to be safely used in conjunction with
108.Xr xargs 1 .
109If a file name contains any of the delimiting characters used by
110.Xr xargs 1 ,
111a diagnostic message is displayed on standard error, and the file
112is skipped.
113The delimiting characters include single
114.Pq Dq Li " ' "
115and double
116.Pq Dq Li " \*q "
117quotes, backslash
118.Pq Dq Li \e ,
119space, tab and newline characters.
120.Pp
121However, you may wish to consider the
122.Fl print0
123primary in conjunction with
124.Ql xargs -0
125as an effective alternative.
120.It Fl d
121The
122.Fl d
123option causes
124.Nm
125to perform a depth\-first traversal, i.e., directories
126are visited in post\-order and all entries in a directory will be acted
127on before the directory itself.
128By default,
129.Nm
130visits directories in pre\-order, i.e., before their contents.
131Note, the default is
132.Em not
133a breadth\-first traversal.
134.It Fl f
135The
136.Fl f
137option specifies a file hierarchy for
138.Nm
139to traverse.
140File hierarchies may also be specified as the operands immediately
141following the options.
142.It Fl s
143The
144.Fl s
145option causes
146.Nm
147to traverse the file hierarchies in lexicographical order,
148i.e., alphabetical order within each directory.
149Note:
150.Ql find -s
151and
152.Ql "find | sort"
153may give different results.
154.It Fl x
155The
156.Fl x
157option prevents
158.Nm
159from descending into directories that have a device number different
160than that of the file from which the descent began.
161.El
162.Sh PRIMARIES
163.Bl -tag -width indent
164.It Ic -amin Ar n
165True if the difference between the file last access time and the time
166.Nm
167was started, rounded up to the next full minute, is
168.Ar n
169minutes.
170.It Ic -anewer Ar file
171Same as
172.Ic -neweram .
173.It Ic -atime Ar n Ns Op Cm smhdw
174If no units are specified, this primary evaluates to
175true if the difference between the file last access time and the time
176.Nm
177was started, rounded up to the next full 24\-hour period, is
178.Ar n
17924\-hour periods.
180.Pp
181If units are specified, this primary evaluates to
182true if the difference between the file last access time and the time
183.Nm
184was started is exactly
185.Ar n
186units.
187Possible time units are as follows:
188.Pp
189.Bl -tag -width indent -compact
190.It Cm s
191second
192.It Cm m
193minute (60 seconds)
194.It Cm h
195hour (60 minutes)
196.It Cm d
197day (24 hours)
198.It Cm w
199week (7 days)
200.El
201.Pp
202Any number of units may be combined in one
203.Ic -atime
204argument, for example,
205.Dq Li "-atime -1h30m" .
206Units are probably only useful when used in conjunction with the
207.Cm +
208or
209.Cm -
210modifier.
211.It Ic -cmin Ar n
212True if the difference between the time of last change of file status
213information and the time
214.Nm
215was started, rounded up to the next full minute, is
216.Ar n
217minutes.
218.It Ic -cnewer Ar file
219Same as
220.Ic -newercm .
221.It Ic -ctime Ar n Ns Op Cm smhdw
222If no units are specified, this primary evaluates to
223true if the difference between the time of last change of file status
224information and the time
225.Nm
226was started, rounded up to the next full 24\-hour period, is
227.Ar n
22824\-hour periods.
229.Pp
230If units are specified, this primary evaluates to
231true if the difference between the time of last change of file status
232information and the time
233.Nm
234was started is exactly
235.Ar n
236units.
237Please refer to the
238.Ic -atime
239primary description for information on supported time units.
240.It Ic -delete
241Delete found files and/or directories.
242Always returns true.
243This executes
244from the current working directory as
245.Nm
246recurses down the tree.
247It will not attempt to delete a filename with a
248.Dq Pa /
249character in its pathname relative to
250.Dq Pa \&.
251for security reasons.
252Depth\-first traversal processing is implied by this option.
253.It Ic -depth
254Always true;
255same as the
256.Fl d
257option.
258.Ic -depth
259can be useful when
260.Nm
261is used with
262.Xr cpio 1
263to process files that are contained in directories with unusual permissions.
264It ensures that you have write permission while you are placing files in a
265directory, then sets the directory's permissions as the last thing.
266.It Ic -empty
267True if the current file or directory is empty.
268.It Ic -exec Ar utility Op Ar argument ... ;
269True if the program named
270.Ar utility
271returns a zero value as its exit status.
272Optional
273.Ar arguments
274may be passed to the utility.
275The expression must be terminated by a semicolon
276.Pq Dq Li \&; .
277If the string
278.Dq Li {}
279appears anywhere in the utility name or the
280arguments it is replaced by the pathname of the current file.
281.Ar Utility
282will be executed from the directory from which
283.Nm
284was executed.
285.Ar Utility
286and
287.Ar arguments
288are not subject to the further expansion of shell patterns
289and constructs.
290.It Ic -execdir Ar utility Op Ar argument ... ;
291The
292.Ic -execdir
293primary is identical to the
294.Ic -exec
295primary with the exception that
296.Ar utility
297will be executed from the directory that holds
298the current file.
299The filename substituted for
300the string
301.Dq Li {}
302is not qualified.
303.It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags
304The flags are specified using symbolic names (see
305.Xr chflags 1 ) .
306Those with the
307.Qq Li no
308prefix (except
309.Qq Li nodump )
310are said to be
311.Ar notflags .
312Flags in
313.Ar flags
314are checked to be set, and flags in
315.Ar notflags
316are checked to be not set.
317Note that this is different from
318.Ic -perm ,
319which only allows the user to specify mode bits that are set.
320.Pp
321If flags are preceded by a dash
322.Pq Dq Li - ,
323this primary evaluates to true
324if at least all of the bits in
325.Ar flags
326and none of the bits in
327.Ar notflags
328are set in the file's flags bits.
329If flags are preceded by a plus
330.Pq Dq Li + ,
331this primary evaluates to true
332if any of the bits in
333.Ar flags
334is set in the file's flags bits,
335or any of the bits in
336.Ar notflags
337is not set in the file's flags bits.
338Otherwise,
339this primary evaluates to true
340if the bits in
341.Ar flags
342exactly match the file's flags bits,
343and none of the
344.Ar flags
345bits match those of
346.Ar notflags .
347.It Ic -fstype Ar type
348True if the file is contained in a file system of type
349.Ar type .
350The
351.Xr sysctl 8
352command can be used to find out the types of filesystems
353that are available on the system:
354.Pp
355.Dl "sysctl vfs"
356.Pp
357In addition, there are two pseudo-types,
358.Dq Li local
359and
360.Dq Li rdonly .
361The former matches any file system physically mounted on the system where
362the
363.Nm
364is being executed and the latter matches any file system which is
365mounted read-only.
366.It Ic -group Ar gname
367True if the file belongs to the group
368.Ar gname .
369If
370.Ar gname
371is numeric and there is no such group name, then
372.Ar gname
373is treated as a group ID.
374.It Ic -iname Ar pattern
375Like
376.Ic -name ,
377but the match is case insensitive.
378.It Ic -inum Ar n
379True if the file has inode number
380.Ar n .
381.It Ic -ipath Ar pattern
382Like
383.Ic -path ,
384but the match is case insensitive.
385.It Ic -iregex Ar pattern
386Like
387.Ic -regex ,
388but the match is case insensitive.
389.It Ic -links Ar n
390True if the file has
391.Ar n
392links.
393.It Ic -ls
394This primary always evaluates to true.
395The following information for the current file is written to standard output:
396its inode number, size in 512\-byte blocks, file permissions, number of hard
397links, owner, group, size in bytes, last modification time, and pathname.
398If the file is a block or character special file, the major and minor numbers
399will be displayed instead of the size in bytes.
400If the file is a symbolic link, the pathname of the linked\-to file will be
401displayed preceded by
402.Dq Li -> .
403The format is identical to that produced by
404.Bk -words
405.Nm ls Fl dgils .
406.Ek
407.It Ic -maxdepth Ar n
408True if the depth of the current file into the tree is less than or equal to
409.Ar n .
410.It Ic -mindepth Ar n
411True if the depth of the current file into the tree is greater than or equal to
412.Ar n .
413.It Ic -mmin Ar n
414True if the difference between the file last modification time and the time
415.Nm
416was started, rounded up to the next full minute, is
417.Ar n
418minutes.
419.It Ic -mnewer Ar file
420Same as
421.Ic -newer .
422.It Ic -mtime Ar n Ns Op Cm smhdw
423If no units are specified, this primary evaluates to
424true if the difference between the file last modification time and the time
425.Nm
426was started, rounded up to the next full 24\-hour period, is
427.Ar n
42824\-hour periods.
429.Pp
430If units are specified, this primary evaluates to
431true if the difference between the file last modification time and the time
432.Nm
433was started is exactly
434.Ar n
435units.
436Please refer to the
437.Ic -atime
438primary description for information on supported time units.
439.It Ic -name Ar pattern
440True if the last component of the pathname being examined matches
441.Ar pattern .
442Special shell pattern matching characters
443.Dq ( Li \&[ ,
444.Dq Li \&] ,
445.Dq Li * ,
446and
447.Dq Li \&? )
448may be used as part of
449.Ar pattern .
450These characters may be matched explicitly by escaping them with a
451backslash
452.Pq Dq Li \e .
453.It Ic -newer Ar file
454True if the current file has a more recent last modification time than
455.Ar file .
456.It Ic -newer Ns Ar X Ns Ar Y Ar file
457True if the current file has a more recent last access time
458.Ar ( X Ns = Ns Cm a ) ,
459change time
460.Ar ( X Ns = Ns Cm c ) ,
461or modification time
462.Ar ( X Ns = Ns Cm m )
463than the last access time
464.Ar ( Y Ns = Ns Cm a ) ,
465change time
466.Ar ( Y Ns = Ns Cm c ) ,
467or modification time
468.Ar ( Y Ns = Ns Cm m )
469of
470.Ar file .
471In addition, if
472.Ar Y Ns = Ns Cm t ,
473then
474.Ar file
475is instead interpreted as a direct date specification of the form
476understood by
477.Xr cvs 1 .
478Note that
479.Ic -newermm
480is equivalent to
481.Ic -newer .
482.It Ic -nogroup
483True if the file belongs to an unknown group.
484.It Ic -nouser
485True if the file belongs to an unknown user.
486.It Ic -ok Ar utility Op Ar argument ... ;
487The
488.Ic -ok
489primary is identical to the
490.Ic -exec
491primary with the exception that
492.Nm
493requests user affirmation for the execution of the
494.Ar utility
495by printing
496a message to the terminal and reading a response.
497If the response is other than
498.Dq Li y
499the command is not executed and the
500value of the
501.Ic -ok
502expression is false.
503.It Ic -okdir Ar utility Op Ar argument ... ;
504The
505.Ic -okdir
506primary is identical to the
507.Ic -execdir
508primary with the same exception as described for the
509.Ic -ok
510primary.
511.It Ic -path Ar pattern
512True if the pathname being examined matches
513.Ar pattern .
514Special shell pattern matching characters
515.Dq ( Li \&[ ,
516.Dq Li \&] ,
517.Dq Li * ,
518and
519.Dq Li \&? )
520may be used as part of
521.Ar pattern .
522These characters may be matched explicitly by escaping them with a
523backslash
524.Pq Dq Li \e .
525Slashes
526.Pq Dq Li /
527are treated as normal characters and do not have to be
528matched explicitly.
529.It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode
530The
531.Ar mode
532may be either symbolic (see
533.Xr chmod 1 )
534or an octal number.
535If the
536.Ar mode
537is symbolic, a starting value of zero is assumed and the
538.Ar mode
539sets or clears permissions without regard to the process' file mode
540creation mask.
541If the
542.Ar mode
543is octal, only bits 07777
544.Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
545of the file's mode bits participate
546in the comparison.
547If the
548.Ar mode
549is preceded by a dash
550.Pq Dq Li - ,
551this primary evaluates to true
552if at least all of the bits in the
553.Ar mode
554are set in the file's mode bits.
555If the
556.Ar mode
557is preceded by a plus
558.Pq Dq Li + ,
559this primary evaluates to true
560if any of the bits in the
561.Ar mode
562are set in the file's mode bits.
563Otherwise, this primary evaluates to true if
564the bits in the
565.Ar mode
566exactly match the file's mode bits.
567Note, the first character of a symbolic mode may not be a dash
568.Pq Dq Li - .
569.It Ic -print
570This primary always evaluates to true.
571It prints the pathname of the current file to standard output.
572If none of
573.Ic -exec , -ls , -print0 ,
574or
575.Ic -ok
576is specified, the given expression shall be effectively replaced by
577.Cm \&( Ar "given expression" Cm \&) Ic -print .
578.It Ic -print0
579This primary always evaluates to true.
580It prints the pathname of the current file to standard output, followed by an
581.Tn ASCII NUL
582character (character code 0).
583.It Ic -prune
584This primary always evaluates to true.
585It causes
586.Nm
587to not descend into the current file.
588Note, the
589.Ic -prune
590primary has no effect if the
591.Fl d
592option was specified.
593.It Ic -regex Ar pattern
594True if the whole path of the file matches
595.Ar pattern
596using regular expression.
597To match a file named
598.Dq Pa ./foo/xyzzy ,
599you can use the regular expression
600.Dq Li ".*/[xyz]*"
601or
602.Dq Li ".*/foo/.*" ,
603but not
604.Dq Li xyzzy
605or
606.Dq Li /foo/ .
607.It Ic -size Ar n Ns Op Cm c
608True if the file's size, rounded up, in 512\-byte blocks is
609.Ar n .
610If
611.Ar n
612is followed by a
613.Cm c ,
614then the primary is true if the
615file's size is
616.Ar n
617bytes (characters).
618.It Ic -type Ar t
619True if the file is of the specified type.
620Possible file types are as follows:
621.Pp
622.Bl -tag -width indent -compact
623.It Cm b
624block special
625.It Cm c
626character special
627.It Cm d
628directory
629.It Cm f
630regular file
631.It Cm l
632symbolic link
633.It Cm p
634FIFO
635.It Cm s
636socket
637.El
638.It Ic -user Ar uname
639True if the file belongs to the user
640.Ar uname .
641If
642.Ar uname
643is numeric and there is no such user name, then
644.Ar uname
645is treated as a user ID.
646.El
647.Pp
648All primaries which take a numeric argument allow the number to be
649preceded by a plus sign
650.Pq Dq Li +
651or a minus sign
652.Pq Dq Li - .
653A preceding plus sign means
654.Dq more than n ,
655a preceding minus sign means
656.Dq less than n
657and neither means
658.Dq exactly n .
659.Sh OPERATORS
660The primaries may be combined using the following operators.
661The operators are listed in order of decreasing precedence.
662.Pp
663.Bl -tag -width "( expression )" -compact
664.It Cm \&( Ar expression Cm \&)
665This evaluates to true if the parenthesized expression evaluates to
666true.
667.Pp
668.It Cm \&! Ar expression
669This is the unary
670.Tn NOT
671operator.
672It evaluates to true if the expression is false.
673.Pp
674.It Ar expression Cm -and Ar expression
675.It Ar expression expression
676The
677.Cm -and
678operator is the logical
679.Tn AND
680operator.
681As it is implied by the juxtaposition of two expressions it does not
682have to be specified.
683The expression evaluates to true if both expressions are true.
684The second expression is not evaluated if the first expression is false.
685.Pp
686.It Ar expression Cm -or Ar expression
687The
688.Cm -or
689operator is the logical
690.Tn OR
691operator.
692The expression evaluates to true if either the first or the second expression
693is true.
694The second expression is not evaluated if the first expression is true.
695.El
696.Pp
697All operands and primaries must be separate arguments to
698.Nm .
699Primaries which themselves take arguments expect each argument
700to be a separate argument to
701.Nm .
702.Sh EXAMPLES
703The following examples are shown as given to the shell:
704.Bl -tag -width indent
705.It Li "find / \e! -name \*q*.c\*q -print"
706Print out a list of all the files whose names do not end in
707.Pa .c .
708.It Li "find / -newer ttt -user wnj -print"
709Print out a list of all the files owned by user
710.Dq wnj
711that are newer
712than the file
713.Pa ttt .
714.It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
715Print out a list of all the files which are not both newer than
716.Pa ttt
717and owned by
718.Dq wnj .
719.It Li "find / \e( -newer ttt -or -user wnj \e) -print"
720Print out a list of all the files that are either owned by
721.Dq wnj
722or that are newer than
723.Pa ttt .
724.It Li "find . -newerct '1 minute ago' -print"
725Print out a list of all the files whose inode change time is more
726recent than the current time minus one minute.
727.El
728.Sh SEE ALSO
729.Xr chflags 1 ,
730.Xr chmod 1 ,
731.Xr cvs 1 ,
732.Xr locate 1 ,
733.Xr whereis 1 ,
734.Xr which 1 ,
126.It Fl d
127The
128.Fl d
129option causes
130.Nm
131to perform a depth\-first traversal, i.e., directories
132are visited in post\-order and all entries in a directory will be acted
133on before the directory itself.
134By default,
135.Nm
136visits directories in pre\-order, i.e., before their contents.
137Note, the default is
138.Em not
139a breadth\-first traversal.
140.It Fl f
141The
142.Fl f
143option specifies a file hierarchy for
144.Nm
145to traverse.
146File hierarchies may also be specified as the operands immediately
147following the options.
148.It Fl s
149The
150.Fl s
151option causes
152.Nm
153to traverse the file hierarchies in lexicographical order,
154i.e., alphabetical order within each directory.
155Note:
156.Ql find -s
157and
158.Ql "find | sort"
159may give different results.
160.It Fl x
161The
162.Fl x
163option prevents
164.Nm
165from descending into directories that have a device number different
166than that of the file from which the descent began.
167.El
168.Sh PRIMARIES
169.Bl -tag -width indent
170.It Ic -amin Ar n
171True if the difference between the file last access time and the time
172.Nm
173was started, rounded up to the next full minute, is
174.Ar n
175minutes.
176.It Ic -anewer Ar file
177Same as
178.Ic -neweram .
179.It Ic -atime Ar n Ns Op Cm smhdw
180If no units are specified, this primary evaluates to
181true if the difference between the file last access time and the time
182.Nm
183was started, rounded up to the next full 24\-hour period, is
184.Ar n
18524\-hour periods.
186.Pp
187If units are specified, this primary evaluates to
188true if the difference between the file last access time and the time
189.Nm
190was started is exactly
191.Ar n
192units.
193Possible time units are as follows:
194.Pp
195.Bl -tag -width indent -compact
196.It Cm s
197second
198.It Cm m
199minute (60 seconds)
200.It Cm h
201hour (60 minutes)
202.It Cm d
203day (24 hours)
204.It Cm w
205week (7 days)
206.El
207.Pp
208Any number of units may be combined in one
209.Ic -atime
210argument, for example,
211.Dq Li "-atime -1h30m" .
212Units are probably only useful when used in conjunction with the
213.Cm +
214or
215.Cm -
216modifier.
217.It Ic -cmin Ar n
218True if the difference between the time of last change of file status
219information and the time
220.Nm
221was started, rounded up to the next full minute, is
222.Ar n
223minutes.
224.It Ic -cnewer Ar file
225Same as
226.Ic -newercm .
227.It Ic -ctime Ar n Ns Op Cm smhdw
228If no units are specified, this primary evaluates to
229true if the difference between the time of last change of file status
230information and the time
231.Nm
232was started, rounded up to the next full 24\-hour period, is
233.Ar n
23424\-hour periods.
235.Pp
236If units are specified, this primary evaluates to
237true if the difference between the time of last change of file status
238information and the time
239.Nm
240was started is exactly
241.Ar n
242units.
243Please refer to the
244.Ic -atime
245primary description for information on supported time units.
246.It Ic -delete
247Delete found files and/or directories.
248Always returns true.
249This executes
250from the current working directory as
251.Nm
252recurses down the tree.
253It will not attempt to delete a filename with a
254.Dq Pa /
255character in its pathname relative to
256.Dq Pa \&.
257for security reasons.
258Depth\-first traversal processing is implied by this option.
259.It Ic -depth
260Always true;
261same as the
262.Fl d
263option.
264.Ic -depth
265can be useful when
266.Nm
267is used with
268.Xr cpio 1
269to process files that are contained in directories with unusual permissions.
270It ensures that you have write permission while you are placing files in a
271directory, then sets the directory's permissions as the last thing.
272.It Ic -empty
273True if the current file or directory is empty.
274.It Ic -exec Ar utility Op Ar argument ... ;
275True if the program named
276.Ar utility
277returns a zero value as its exit status.
278Optional
279.Ar arguments
280may be passed to the utility.
281The expression must be terminated by a semicolon
282.Pq Dq Li \&; .
283If the string
284.Dq Li {}
285appears anywhere in the utility name or the
286arguments it is replaced by the pathname of the current file.
287.Ar Utility
288will be executed from the directory from which
289.Nm
290was executed.
291.Ar Utility
292and
293.Ar arguments
294are not subject to the further expansion of shell patterns
295and constructs.
296.It Ic -execdir Ar utility Op Ar argument ... ;
297The
298.Ic -execdir
299primary is identical to the
300.Ic -exec
301primary with the exception that
302.Ar utility
303will be executed from the directory that holds
304the current file.
305The filename substituted for
306the string
307.Dq Li {}
308is not qualified.
309.It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags
310The flags are specified using symbolic names (see
311.Xr chflags 1 ) .
312Those with the
313.Qq Li no
314prefix (except
315.Qq Li nodump )
316are said to be
317.Ar notflags .
318Flags in
319.Ar flags
320are checked to be set, and flags in
321.Ar notflags
322are checked to be not set.
323Note that this is different from
324.Ic -perm ,
325which only allows the user to specify mode bits that are set.
326.Pp
327If flags are preceded by a dash
328.Pq Dq Li - ,
329this primary evaluates to true
330if at least all of the bits in
331.Ar flags
332and none of the bits in
333.Ar notflags
334are set in the file's flags bits.
335If flags are preceded by a plus
336.Pq Dq Li + ,
337this primary evaluates to true
338if any of the bits in
339.Ar flags
340is set in the file's flags bits,
341or any of the bits in
342.Ar notflags
343is not set in the file's flags bits.
344Otherwise,
345this primary evaluates to true
346if the bits in
347.Ar flags
348exactly match the file's flags bits,
349and none of the
350.Ar flags
351bits match those of
352.Ar notflags .
353.It Ic -fstype Ar type
354True if the file is contained in a file system of type
355.Ar type .
356The
357.Xr sysctl 8
358command can be used to find out the types of filesystems
359that are available on the system:
360.Pp
361.Dl "sysctl vfs"
362.Pp
363In addition, there are two pseudo-types,
364.Dq Li local
365and
366.Dq Li rdonly .
367The former matches any file system physically mounted on the system where
368the
369.Nm
370is being executed and the latter matches any file system which is
371mounted read-only.
372.It Ic -group Ar gname
373True if the file belongs to the group
374.Ar gname .
375If
376.Ar gname
377is numeric and there is no such group name, then
378.Ar gname
379is treated as a group ID.
380.It Ic -iname Ar pattern
381Like
382.Ic -name ,
383but the match is case insensitive.
384.It Ic -inum Ar n
385True if the file has inode number
386.Ar n .
387.It Ic -ipath Ar pattern
388Like
389.Ic -path ,
390but the match is case insensitive.
391.It Ic -iregex Ar pattern
392Like
393.Ic -regex ,
394but the match is case insensitive.
395.It Ic -links Ar n
396True if the file has
397.Ar n
398links.
399.It Ic -ls
400This primary always evaluates to true.
401The following information for the current file is written to standard output:
402its inode number, size in 512\-byte blocks, file permissions, number of hard
403links, owner, group, size in bytes, last modification time, and pathname.
404If the file is a block or character special file, the major and minor numbers
405will be displayed instead of the size in bytes.
406If the file is a symbolic link, the pathname of the linked\-to file will be
407displayed preceded by
408.Dq Li -> .
409The format is identical to that produced by
410.Bk -words
411.Nm ls Fl dgils .
412.Ek
413.It Ic -maxdepth Ar n
414True if the depth of the current file into the tree is less than or equal to
415.Ar n .
416.It Ic -mindepth Ar n
417True if the depth of the current file into the tree is greater than or equal to
418.Ar n .
419.It Ic -mmin Ar n
420True if the difference between the file last modification time and the time
421.Nm
422was started, rounded up to the next full minute, is
423.Ar n
424minutes.
425.It Ic -mnewer Ar file
426Same as
427.Ic -newer .
428.It Ic -mtime Ar n Ns Op Cm smhdw
429If no units are specified, this primary evaluates to
430true if the difference between the file last modification time and the time
431.Nm
432was started, rounded up to the next full 24\-hour period, is
433.Ar n
43424\-hour periods.
435.Pp
436If units are specified, this primary evaluates to
437true if the difference between the file last modification time and the time
438.Nm
439was started is exactly
440.Ar n
441units.
442Please refer to the
443.Ic -atime
444primary description for information on supported time units.
445.It Ic -name Ar pattern
446True if the last component of the pathname being examined matches
447.Ar pattern .
448Special shell pattern matching characters
449.Dq ( Li \&[ ,
450.Dq Li \&] ,
451.Dq Li * ,
452and
453.Dq Li \&? )
454may be used as part of
455.Ar pattern .
456These characters may be matched explicitly by escaping them with a
457backslash
458.Pq Dq Li \e .
459.It Ic -newer Ar file
460True if the current file has a more recent last modification time than
461.Ar file .
462.It Ic -newer Ns Ar X Ns Ar Y Ar file
463True if the current file has a more recent last access time
464.Ar ( X Ns = Ns Cm a ) ,
465change time
466.Ar ( X Ns = Ns Cm c ) ,
467or modification time
468.Ar ( X Ns = Ns Cm m )
469than the last access time
470.Ar ( Y Ns = Ns Cm a ) ,
471change time
472.Ar ( Y Ns = Ns Cm c ) ,
473or modification time
474.Ar ( Y Ns = Ns Cm m )
475of
476.Ar file .
477In addition, if
478.Ar Y Ns = Ns Cm t ,
479then
480.Ar file
481is instead interpreted as a direct date specification of the form
482understood by
483.Xr cvs 1 .
484Note that
485.Ic -newermm
486is equivalent to
487.Ic -newer .
488.It Ic -nogroup
489True if the file belongs to an unknown group.
490.It Ic -nouser
491True if the file belongs to an unknown user.
492.It Ic -ok Ar utility Op Ar argument ... ;
493The
494.Ic -ok
495primary is identical to the
496.Ic -exec
497primary with the exception that
498.Nm
499requests user affirmation for the execution of the
500.Ar utility
501by printing
502a message to the terminal and reading a response.
503If the response is other than
504.Dq Li y
505the command is not executed and the
506value of the
507.Ic -ok
508expression is false.
509.It Ic -okdir Ar utility Op Ar argument ... ;
510The
511.Ic -okdir
512primary is identical to the
513.Ic -execdir
514primary with the same exception as described for the
515.Ic -ok
516primary.
517.It Ic -path Ar pattern
518True if the pathname being examined matches
519.Ar pattern .
520Special shell pattern matching characters
521.Dq ( Li \&[ ,
522.Dq Li \&] ,
523.Dq Li * ,
524and
525.Dq Li \&? )
526may be used as part of
527.Ar pattern .
528These characters may be matched explicitly by escaping them with a
529backslash
530.Pq Dq Li \e .
531Slashes
532.Pq Dq Li /
533are treated as normal characters and do not have to be
534matched explicitly.
535.It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode
536The
537.Ar mode
538may be either symbolic (see
539.Xr chmod 1 )
540or an octal number.
541If the
542.Ar mode
543is symbolic, a starting value of zero is assumed and the
544.Ar mode
545sets or clears permissions without regard to the process' file mode
546creation mask.
547If the
548.Ar mode
549is octal, only bits 07777
550.Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
551of the file's mode bits participate
552in the comparison.
553If the
554.Ar mode
555is preceded by a dash
556.Pq Dq Li - ,
557this primary evaluates to true
558if at least all of the bits in the
559.Ar mode
560are set in the file's mode bits.
561If the
562.Ar mode
563is preceded by a plus
564.Pq Dq Li + ,
565this primary evaluates to true
566if any of the bits in the
567.Ar mode
568are set in the file's mode bits.
569Otherwise, this primary evaluates to true if
570the bits in the
571.Ar mode
572exactly match the file's mode bits.
573Note, the first character of a symbolic mode may not be a dash
574.Pq Dq Li - .
575.It Ic -print
576This primary always evaluates to true.
577It prints the pathname of the current file to standard output.
578If none of
579.Ic -exec , -ls , -print0 ,
580or
581.Ic -ok
582is specified, the given expression shall be effectively replaced by
583.Cm \&( Ar "given expression" Cm \&) Ic -print .
584.It Ic -print0
585This primary always evaluates to true.
586It prints the pathname of the current file to standard output, followed by an
587.Tn ASCII NUL
588character (character code 0).
589.It Ic -prune
590This primary always evaluates to true.
591It causes
592.Nm
593to not descend into the current file.
594Note, the
595.Ic -prune
596primary has no effect if the
597.Fl d
598option was specified.
599.It Ic -regex Ar pattern
600True if the whole path of the file matches
601.Ar pattern
602using regular expression.
603To match a file named
604.Dq Pa ./foo/xyzzy ,
605you can use the regular expression
606.Dq Li ".*/[xyz]*"
607or
608.Dq Li ".*/foo/.*" ,
609but not
610.Dq Li xyzzy
611or
612.Dq Li /foo/ .
613.It Ic -size Ar n Ns Op Cm c
614True if the file's size, rounded up, in 512\-byte blocks is
615.Ar n .
616If
617.Ar n
618is followed by a
619.Cm c ,
620then the primary is true if the
621file's size is
622.Ar n
623bytes (characters).
624.It Ic -type Ar t
625True if the file is of the specified type.
626Possible file types are as follows:
627.Pp
628.Bl -tag -width indent -compact
629.It Cm b
630block special
631.It Cm c
632character special
633.It Cm d
634directory
635.It Cm f
636regular file
637.It Cm l
638symbolic link
639.It Cm p
640FIFO
641.It Cm s
642socket
643.El
644.It Ic -user Ar uname
645True if the file belongs to the user
646.Ar uname .
647If
648.Ar uname
649is numeric and there is no such user name, then
650.Ar uname
651is treated as a user ID.
652.El
653.Pp
654All primaries which take a numeric argument allow the number to be
655preceded by a plus sign
656.Pq Dq Li +
657or a minus sign
658.Pq Dq Li - .
659A preceding plus sign means
660.Dq more than n ,
661a preceding minus sign means
662.Dq less than n
663and neither means
664.Dq exactly n .
665.Sh OPERATORS
666The primaries may be combined using the following operators.
667The operators are listed in order of decreasing precedence.
668.Pp
669.Bl -tag -width "( expression )" -compact
670.It Cm \&( Ar expression Cm \&)
671This evaluates to true if the parenthesized expression evaluates to
672true.
673.Pp
674.It Cm \&! Ar expression
675This is the unary
676.Tn NOT
677operator.
678It evaluates to true if the expression is false.
679.Pp
680.It Ar expression Cm -and Ar expression
681.It Ar expression expression
682The
683.Cm -and
684operator is the logical
685.Tn AND
686operator.
687As it is implied by the juxtaposition of two expressions it does not
688have to be specified.
689The expression evaluates to true if both expressions are true.
690The second expression is not evaluated if the first expression is false.
691.Pp
692.It Ar expression Cm -or Ar expression
693The
694.Cm -or
695operator is the logical
696.Tn OR
697operator.
698The expression evaluates to true if either the first or the second expression
699is true.
700The second expression is not evaluated if the first expression is true.
701.El
702.Pp
703All operands and primaries must be separate arguments to
704.Nm .
705Primaries which themselves take arguments expect each argument
706to be a separate argument to
707.Nm .
708.Sh EXAMPLES
709The following examples are shown as given to the shell:
710.Bl -tag -width indent
711.It Li "find / \e! -name \*q*.c\*q -print"
712Print out a list of all the files whose names do not end in
713.Pa .c .
714.It Li "find / -newer ttt -user wnj -print"
715Print out a list of all the files owned by user
716.Dq wnj
717that are newer
718than the file
719.Pa ttt .
720.It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
721Print out a list of all the files which are not both newer than
722.Pa ttt
723and owned by
724.Dq wnj .
725.It Li "find / \e( -newer ttt -or -user wnj \e) -print"
726Print out a list of all the files that are either owned by
727.Dq wnj
728or that are newer than
729.Pa ttt .
730.It Li "find . -newerct '1 minute ago' -print"
731Print out a list of all the files whose inode change time is more
732recent than the current time minus one minute.
733.El
734.Sh SEE ALSO
735.Xr chflags 1 ,
736.Xr chmod 1 ,
737.Xr cvs 1 ,
738.Xr locate 1 ,
739.Xr whereis 1 ,
740.Xr which 1 ,
741.Xr xargs 1 ,
735.Xr stat 2 ,
736.Xr fts 3 ,
737.Xr getgrent 3 ,
738.Xr getpwent 3 ,
739.Xr strmode 3 ,
740.Xr re_format 7 ,
741.Xr symlink 7
742.Sh STANDARDS
743The
744.Nm
745utility syntax is a superset of the syntax specified by the
746.St -p1003.2
747standard.
748.Pp
749All the single character options as well as the
750.Ic -iname , -inum , -iregex , -print0 , -delete , -ls ,
751and
752.Ic -regex
753primaries are extensions to
754.St -p1003.2 .
755.Pp
756Historically, the
757.Fl d , h
758and
759.Fl x
760options were implemented using the primaries
761.Ic -depth , -follow ,
762and
763.Ic -xdev .
764These primaries always evaluated to true.
765As they were really global variables that took effect before the traversal
766began, some legal expressions could have unexpected results.
767An example is the expression
768.Ic -print Cm -o Ic -depth .
769As
770.Ic -print
771always evaluates to true, the standard order of evaluation
772implies that
773.Ic -depth
774would never be evaluated.
775This is not the case.
776.Pp
777The operator
778.Cm -or
779was implemented as
780.Cm -o ,
781and the operator
782.Cm -and
783was implemented as
784.Cm -a .
785.Pp
786Historic implementations of the
787.Ic -exec
788and
789.Ic -ok
790primaries did not replace the string
791.Dq Li {}
792in the utility name or the
793utility arguments if it had preceding or following non-whitespace characters.
794This version replaces it no matter where in the utility name or arguments
795it appears.
796.Pp
797The
798.Fl E
799option was implemented on the analogy of
800.Xr grep 1
801and
802.Xr sed 1 .
803.Sh BUGS
804The special characters used by
805.Nm
806are also special characters to many shell programs.
807In particular, the characters
808.Dq Li * ,
809.Dq Li \&[ ,
810.Dq Li \&] ,
811.Dq Li \&? ,
812.Dq Li \&( ,
813.Dq Li \&) ,
814.Dq Li \&! ,
815.Dq Li \e
816and
817.Dq Li \&;
818may have to be escaped from the shell.
819.Pp
820As there is no delimiter separating options and file names or file
821names and the
822.Ar expression ,
823it is difficult to specify files named
824.Pa -xdev
825or
826.Pa \&! .
827These problems are handled by the
828.Fl f
829option and the
830.Xr getopt 3
831.Dq Fl Fl
832construct.
833.Pp
834The
835.Ic -delete
836primary does not interact well with other options that cause the filesystem
837tree traversal options to be changed.
838.Sh HISTORY
839A
840.Nm
841command appeared in
842.At v1 .
742.Xr stat 2 ,
743.Xr fts 3 ,
744.Xr getgrent 3 ,
745.Xr getpwent 3 ,
746.Xr strmode 3 ,
747.Xr re_format 7 ,
748.Xr symlink 7
749.Sh STANDARDS
750The
751.Nm
752utility syntax is a superset of the syntax specified by the
753.St -p1003.2
754standard.
755.Pp
756All the single character options as well as the
757.Ic -iname , -inum , -iregex , -print0 , -delete , -ls ,
758and
759.Ic -regex
760primaries are extensions to
761.St -p1003.2 .
762.Pp
763Historically, the
764.Fl d , h
765and
766.Fl x
767options were implemented using the primaries
768.Ic -depth , -follow ,
769and
770.Ic -xdev .
771These primaries always evaluated to true.
772As they were really global variables that took effect before the traversal
773began, some legal expressions could have unexpected results.
774An example is the expression
775.Ic -print Cm -o Ic -depth .
776As
777.Ic -print
778always evaluates to true, the standard order of evaluation
779implies that
780.Ic -depth
781would never be evaluated.
782This is not the case.
783.Pp
784The operator
785.Cm -or
786was implemented as
787.Cm -o ,
788and the operator
789.Cm -and
790was implemented as
791.Cm -a .
792.Pp
793Historic implementations of the
794.Ic -exec
795and
796.Ic -ok
797primaries did not replace the string
798.Dq Li {}
799in the utility name or the
800utility arguments if it had preceding or following non-whitespace characters.
801This version replaces it no matter where in the utility name or arguments
802it appears.
803.Pp
804The
805.Fl E
806option was implemented on the analogy of
807.Xr grep 1
808and
809.Xr sed 1 .
810.Sh BUGS
811The special characters used by
812.Nm
813are also special characters to many shell programs.
814In particular, the characters
815.Dq Li * ,
816.Dq Li \&[ ,
817.Dq Li \&] ,
818.Dq Li \&? ,
819.Dq Li \&( ,
820.Dq Li \&) ,
821.Dq Li \&! ,
822.Dq Li \e
823and
824.Dq Li \&;
825may have to be escaped from the shell.
826.Pp
827As there is no delimiter separating options and file names or file
828names and the
829.Ar expression ,
830it is difficult to specify files named
831.Pa -xdev
832or
833.Pa \&! .
834These problems are handled by the
835.Fl f
836option and the
837.Xr getopt 3
838.Dq Fl Fl
839construct.
840.Pp
841The
842.Ic -delete
843primary does not interact well with other options that cause the filesystem
844tree traversal options to be changed.
845.Sh HISTORY
846A
847.Nm
848command appeared in
849.At v1 .