xref: /freebsd/usr.bin/find/find.1 (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)find.1	8.7 (Berkeley) 5/9/95
32.\" $FreeBSD$
33.\"
34.Dd January 24, 2017
35.Dt FIND 1
36.Os
37.Sh NAME
38.Nm find
39.Nd walk a file hierarchy
40.Sh SYNOPSIS
41.Nm
42.Op Fl H | Fl L | Fl P
43.Op Fl EXdsx
44.Op Fl f Ar path
45.Ar path ...
46.Op Ar expression
47.Nm
48.Op Fl H | Fl L | Fl P
49.Op Fl EXdsx
50.Fl f Ar path
51.Op Ar path ...
52.Op Ar expression
53.Sh DESCRIPTION
54The
55.Nm
56utility recursively descends the directory tree for each
57.Ar path
58listed, evaluating an
59.Ar expression
60(composed of the
61.Dq primaries
62and
63.Dq operands
64listed below) in terms
65of each file in the tree.
66.Pp
67The options are as follows:
68.Bl -tag -width indent
69.It Fl E
70Interpret regular expressions followed by
71.Ic -regex
72and
73.Ic -iregex
74primaries as extended (modern) regular expressions rather than basic
75regular expressions (BRE's).
76The
77.Xr re_format 7
78manual page fully describes both formats.
79.It Fl H
80Cause the file information and file type (see
81.Xr stat 2 )
82returned for each symbolic link specified on the command line to be
83those of the file referenced by the link, not the link itself.
84If the referenced file does not exist, the file information and type will
85be for the link itself.
86File information of all symbolic links not on
87the command line is that of the link itself.
88.It Fl L
89Cause 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.Pp
96This option is equivalent to the deprecated
97.Ic -follow
98primary.
99.It Fl P
100Cause the file information and file type (see
101.Xr stat 2 )
102returned for each symbolic link to be those of the link itself.
103This is the default.
104.It Fl X
105Permit
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.Dq Nm xargs Fl 0
125as an effective alternative.
126.It Fl d
127Cause
128.Nm
129to perform a depth-first traversal.
130.Pp
131This option is a BSD-specific equivalent of the
132.Ic -depth
133primary specified by
134.St -p1003.1-2001 .
135Refer to its description under
136.Sx PRIMARIES
137for more information.
138.It Fl s
139Cause
140.Nm
141to traverse the file hierarchies in lexicographical order,
142i.e., alphabetical order within each directory.
143Note:
144.Ql find -s
145and
146.Ql "find | sort"
147may give different results.
148.It Fl x
149Prevent
150.Nm
151from descending into directories that have a device number different
152than that of the file from which the descent began.
153.Pp
154This option is equivalent to the deprecated
155.Ic -xdev
156primary.
157.El
158.Sh PRIMARIES
159All primaries which take a numeric argument allow the number to be
160preceded by a plus sign
161.Pq Dq Li +
162or a minus sign
163.Pq Dq Li - .
164A preceding plus sign means
165.Dq more than n ,
166a preceding minus sign means
167.Dq less than n
168and neither means
169.Dq exactly n .
170.Bl -tag -width indent
171.It Ic -Bmin Ar n
172True if the difference between the time of a file's inode creation
173and the time
174.Nm
175was started, rounded up to the next full minute, is
176.Ar n
177minutes.
178.It Ic -Bnewer Ar file
179Same as
180.Ic -newerBm .
181.It Ic -Btime Ar n Ns Op Cm smhdw
182If no units are specified, this primary evaluates to
183true if the difference between the time of a file's inode creation
184and the time
185.Nm
186was started, rounded up to the next full 24-hour period, is
187.Ar n
18824-hour periods.
189.Pp
190If units are specified, this primary evaluates to
191true if the difference between the time of a file's inode creation
192and the time
193.Nm
194was started is exactly
195.Ar n
196units.
197Please refer to the
198.Ic -atime
199primary description for information on supported time units.
200.It Ic -acl
201May be used in conjunction with other primaries to locate
202files with extended ACLs.
203See
204.Xr acl 3
205for more information.
206.It Ic -amin Oo Cm - Ns | Ns Cm + Oc Ns Ar n
207True if the difference between the file last access time and the time
208.Nm
209was started, rounded up to the next full minute, is
210more than
211.Ar n
212.Pq + Ns Ar n ,
213less than
214.Ar n
215.Pq - Ns Ar n ,
216or exactly
217.Ar n
218minutes ago.
219.It Ic -anewer Ar file
220Same as
221.Ic -neweram .
222.It Ic -atime Ar n Ns Op Cm smhdw
223If no units are specified, this primary evaluates to
224true if the difference between the file last access time 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 file last access time and the time
232.Nm
233was started is exactly
234.Ar n
235units.
236Possible time units are as follows:
237.Pp
238.Bl -tag -width indent -compact
239.It Cm s
240second
241.It Cm m
242minute (60 seconds)
243.It Cm h
244hour (60 minutes)
245.It Cm d
246day (24 hours)
247.It Cm w
248week (7 days)
249.El
250.Pp
251Any number of units may be combined in one
252.Ic -atime
253argument, for example,
254.Dq Li "-atime -1h30m" .
255Units are probably only useful when used in conjunction with the
256.Cm +
257or
258.Cm -
259modifier.
260.It Ic -cmin Oo Cm - Ns | Ns Cm + Oc Ns Ar n
261True if the difference between the time of last change of file status
262information and the time
263.Nm
264was started, rounded up to the next full minute, is
265more than
266.Ar n
267.Pq + Ns Ar n ,
268less than
269.Ar n
270.Pq - Ns Ar n ,
271or exactly
272.Ar n
273minutes ago.
274.It Ic -cnewer Ar file
275Same as
276.Ic -newercm .
277.It Ic -ctime Ar n Ns Op Cm smhdw
278If no units are specified, this primary evaluates to
279true if the difference between the time of last change of file status
280information and the time
281.Nm
282was started, rounded up to the next full 24-hour period, is
283.Ar n
28424-hour periods.
285.Pp
286If units are specified, this primary evaluates to
287true if the difference between the time of last change of file status
288information and the time
289.Nm
290was started is exactly
291.Ar n
292units.
293Please refer to the
294.Ic -atime
295primary description for information on supported time units.
296.It Ic -d
297Non-portable, BSD-specific version of
298.Ic depth .
299GNU find implements this as a primary in mistaken emulation of
300.Fx
301.Nm .
302.It Ic -delete
303Delete found files and/or directories.
304Always returns true.
305This executes
306from the current working directory as
307.Nm
308recurses down the tree.
309It will not attempt to delete a filename with a
310.Dq Pa /
311character in its pathname relative to
312.Dq Pa \&.
313for security reasons.
314Depth-first traversal processing is implied by this option.
315The
316.Ic -delete
317primary will fail to delete a directory if it is not empty.
318Following symlinks is incompatible with this option.
319.It Ic -depth
320Always true;
321same as the non-portable
322.Fl d
323option.
324Cause
325.Nm
326to perform a depth-first traversal, i.e., directories
327are visited in post-order and all entries in a directory will be acted
328on before the directory itself.
329By default,
330.Nm
331visits directories in pre-order, i.e., before their contents.
332Note, the default is
333.Em not
334a breadth-first traversal.
335.Pp
336The
337.Ic -depth
338primary
339can be useful when
340.Nm
341is used with
342.Xr cpio 1
343to process files that are contained in directories with unusual permissions.
344It ensures that you have write permission while you are placing files in a
345directory, then sets the directory's permissions as the last thing.
346.It Ic -depth Ar n
347True if the depth of the file relative to the starting point of the traversal
348is
349.Ar n .
350.It Ic -empty
351True if the current file or directory is empty.
352.It Ic -exec Ar utility Oo Ar argument ... Oc Li \&;
353True if the program named
354.Ar utility
355returns a zero value as its exit status.
356Optional
357.Ar arguments
358may be passed to the utility.
359The expression must be terminated by a semicolon
360.Pq Dq Li \&; .
361If you invoke
362.Nm
363from a shell you may need to quote the semicolon if the shell would
364otherwise treat it as a control operator.
365If the string
366.Dq Li {}
367appears anywhere in the utility name or the
368arguments it is replaced by the pathname of the current file.
369.Ar Utility
370will be executed from the directory from which
371.Nm
372was executed.
373.Ar Utility
374and
375.Ar arguments
376are not subject to the further expansion of shell patterns
377and constructs.
378.It Ic -exec Ar utility Oo Ar argument ... Oc Li {} +
379Same as
380.Ic -exec ,
381except that
382.Dq Li {}
383is replaced with as many pathnames as possible for each invocation of
384.Ar utility .
385This behaviour is similar to that of
386.Xr xargs 1 .
387The primary always returns true;
388if at least one invocation of
389.Ar utility
390returns a non-zero exit status,
391.Nm
392will return a non-zero exit status.
393.It Ic -execdir Ar utility Oo Ar argument ... Oc Li \&;
394The
395.Ic -execdir
396primary is identical to the
397.Ic -exec
398primary with the exception that
399.Ar utility
400will be executed from the directory that holds
401the current file.
402The filename substituted for
403the string
404.Dq Li {}
405is not qualified.
406.It Ic -execdir Ar utility Oo Ar argument ... Oc Li {} +
407Same as
408.Ic -execdir ,
409except that
410.Dq Li {}
411is replaced with as many pathnames as possible for each invocation of
412.Ar utility .
413This behaviour is similar to that of
414.Xr xargs 1 .
415The primary always returns true;
416if at least one invocation of
417.Ar utility
418returns a non-zero exit status,
419.Nm
420will return a non-zero exit status.
421.It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags
422The flags are specified using symbolic names (see
423.Xr chflags 1 ) .
424Those with the
425.Qq Li no
426prefix (except
427.Qq Li nodump )
428are said to be
429.Ar notflags .
430Flags in
431.Ar flags
432are checked to be set, and flags in
433.Ar notflags
434are checked to be not set.
435Note that this is different from
436.Ic -perm ,
437which only allows the user to specify mode bits that are set.
438.Pp
439If flags are preceded by a dash
440.Pq Dq Li - ,
441this primary evaluates to true
442if at least all of the bits in
443.Ar flags
444and none of the bits in
445.Ar notflags
446are set in the file's flags bits.
447If flags are preceded by a plus
448.Pq Dq Li + ,
449this primary evaluates to true
450if any of the bits in
451.Ar flags
452is set in the file's flags bits,
453or any of the bits in
454.Ar notflags
455is not set in the file's flags bits.
456Otherwise,
457this primary evaluates to true
458if the bits in
459.Ar flags
460exactly match the file's flags bits,
461and none of the
462.Ar flags
463bits match those of
464.Ar notflags .
465.It Ic -fstype Ar type
466True if the file is contained in a file system of type
467.Ar type .
468The
469.Xr lsvfs 1
470command can be used to find out the types of file systems
471that are available on the system.
472In addition, there are two pseudo-types,
473.Dq Li local
474and
475.Dq Li rdonly .
476The former matches any file system physically mounted on the system where
477the
478.Nm
479is being executed and the latter matches any file system which is
480mounted read-only.
481.It Ic -gid Ar gname
482The same thing as
483.Ar -group Ar gname
484for compatibility with GNU find.
485GNU find imposes a restriction that
486.Ar gname
487is numeric, while
488.Nm
489does not.
490.It Ic -group Ar gname
491True if the file belongs to the group
492.Ar gname .
493If
494.Ar gname
495is numeric and there is no such group name, then
496.Ar gname
497is treated as a group ID.
498.It Ic -ignore_readdir_race
499Ignore errors because a file or a directory is deleted
500after reading the name from a directory.
501This option does not affect errors occurring on starting points.
502.It Ic -ilname Ar pattern
503Like
504.Ic -lname ,
505but the match is case insensitive.
506This is a GNU find extension.
507.It Ic -iname Ar pattern
508Like
509.Ic -name ,
510but the match is case insensitive.
511.It Ic -inum Ar n
512True if the file has inode number
513.Ar n .
514.It Ic -ipath Ar pattern
515Like
516.Ic -path ,
517but the match is case insensitive.
518.It Ic -iregex Ar pattern
519Like
520.Ic -regex ,
521but the match is case insensitive.
522.It Ic -iwholename Ar pattern
523The same thing as
524.Ic -ipath ,
525for GNU find compatibility.
526.It Ic -links Ar n
527True if the file has
528.Ar n
529links.
530.It Ic -lname Ar pattern
531Like
532.Ic -name ,
533but the contents of the symbolic link are matched instead of the file
534name.
535Note that this only matches broken symbolic links
536if symbolic links are being followed.
537This is a GNU find extension.
538.It Ic -ls
539This primary always evaluates to true.
540The following information for the current file is written to standard output:
541its inode number, size in 512-byte blocks, file permissions, number of hard
542links, owner, group, size in bytes, last modification time, and pathname.
543If the file is a block or character special file, the device number
544will be displayed instead of the size in bytes.
545If the file is a symbolic link, the pathname of the linked-to file will be
546displayed preceded by
547.Dq Li -> .
548The format is identical to that produced by
549.Bk -words
550.Dq Nm ls Fl dgils .
551.Ek
552.It Ic -maxdepth Ar n
553Always true; descend at most
554.Ar n
555directory levels below the command line arguments.
556If any
557.Ic -maxdepth
558primary is specified, it applies to the entire expression even if it would
559not normally be evaluated.
560.Dq Ic -maxdepth Li 0
561limits the whole search to the command line arguments.
562.It Ic -mindepth Ar n
563Always true; do not apply any tests or actions at levels less than
564.Ar n .
565If any
566.Ic -mindepth
567primary is specified, it applies to the entire expression even if it would
568not normally be evaluated.
569.Dq Ic -mindepth Li 1
570processes all but the command line arguments.
571.It Ic -mmin Oo Cm - Ns | Ns Cm + Oc Ns Ar n
572True if the difference between the file last modification time and the time
573.Nm
574was started, rounded up to the next full minute, is
575more than
576.Ar n
577.Pq + Ns Ar n ,
578less than
579.Ar n
580.Pq - Ns Ar n ,
581or exactly
582.Ar n
583minutes ago.
584.It Ic -mnewer Ar file
585Same as
586.Ic -newer .
587.It Ic -mount
588The same thing as
589.Ic -xdev ,
590for GNU find compatibility.
591.It Ic -mtime Ar n Ns Op Cm smhdw
592If no units are specified, this primary evaluates to
593true if the difference between the file last modification time and the time
594.Nm
595was started, rounded up to the next full 24-hour period, is
596.Ar n
59724-hour periods.
598.Pp
599If units are specified, this primary evaluates to
600true if the difference between the file last modification time and the time
601.Nm
602was started is exactly
603.Ar n
604units.
605Please refer to the
606.Ic -atime
607primary description for information on supported time units.
608.It Ic -name Ar pattern
609True if the last component of the pathname being examined matches
610.Ar pattern .
611Special shell pattern matching characters
612.Dq ( Li \&[ ,
613.Dq Li \&] ,
614.Dq Li * ,
615and
616.Dq Li \&? )
617may be used as part of
618.Ar pattern .
619These characters may be matched explicitly by escaping them with a
620backslash
621.Pq Dq Li \e .
622.It Ic -newer Ar file
623True if the current file has a more recent last modification time than
624.Ar file .
625.It Ic -newer Ns Ar X Ns Ar Y Ar file
626True if the current file has a more recent last access time
627.Pq Ar X Ns = Ns Cm a ,
628inode creation time
629.Pq Ar X Ns = Ns Cm B ,
630change time
631.Pq Ar X Ns = Ns Cm c ,
632or modification time
633.Pq Ar X Ns = Ns Cm m
634than the last access time
635.Pq Ar Y Ns = Ns Cm a ,
636inode creation time
637.Pq Ar Y Ns = Ns Cm B ,
638change time
639.Pq Ar Y Ns = Ns Cm c ,
640or modification time
641.Pq Ar Y Ns = Ns Cm m
642of
643.Ar file .
644In addition, if
645.Ar Y Ns = Ns Cm t ,
646then
647.Ar file
648is instead interpreted as a direct date specification of the form
649understood by
650.Xr cvs 1 .
651Note that
652.Ic -newermm
653is equivalent to
654.Ic -newer .
655.It Ic -nogroup
656True if the file belongs to an unknown group.
657.It Ic -noignore_readdir_race
658Turn off the effect of
659.Ic -ignore_readdir_race .
660This is default behaviour.
661.It Ic -noleaf
662This option is for GNU find compatibility.
663In GNU find it disables an optimization not relevant to
664.Nm ,
665so it is ignored.
666.It Ic -nouser
667True if the file belongs to an unknown user.
668.It Ic -ok Ar utility Oo Ar argument ... Oc Li \&;
669The
670.Ic -ok
671primary is identical to the
672.Ic -exec
673primary with the exception that
674.Nm
675requests user affirmation for the execution of the
676.Ar utility
677by printing
678a message to the terminal and reading a response.
679If the response is not affirmative
680.Ql ( y
681in the
682.Dq Li POSIX
683locale),
684the command is not executed and the
685value of the
686.Ic -ok
687expression is false.
688.It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&;
689The
690.Ic -okdir
691primary is identical to the
692.Ic -execdir
693primary with the same exception as described for the
694.Ic -ok
695primary.
696.It Ic -path Ar pattern
697True if the pathname being examined matches
698.Ar pattern .
699Special shell pattern matching characters
700.Dq ( Li \&[ ,
701.Dq Li \&] ,
702.Dq Li * ,
703and
704.Dq Li \&? )
705may be used as part of
706.Ar pattern .
707These characters may be matched explicitly by escaping them with a
708backslash
709.Pq Dq Li \e .
710Slashes
711.Pq Dq Li /
712are treated as normal characters and do not have to be
713matched explicitly.
714.It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode
715The
716.Ar mode
717may be either symbolic (see
718.Xr chmod 1 )
719or an octal number.
720If the
721.Ar mode
722is symbolic, a starting value of zero is assumed and the
723.Ar mode
724sets or clears permissions without regard to the process' file mode
725creation mask.
726If the
727.Ar mode
728is octal, only bits 07777
729.Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
730of the file's mode bits participate
731in the comparison.
732If the
733.Ar mode
734is preceded by a dash
735.Pq Dq Li - ,
736this primary evaluates to true
737if at least all of the bits in the
738.Ar mode
739are set in the file's mode bits.
740If the
741.Ar mode
742is preceded by a plus
743.Pq Dq Li + ,
744this primary evaluates to true
745if any of the bits in the
746.Ar mode
747are set in the file's mode bits.
748Otherwise, this primary evaluates to true if
749the bits in the
750.Ar mode
751exactly match the file's mode bits.
752Note, the first character of a symbolic mode may not be a dash
753.Pq Dq Li - .
754.It Ic -print
755This primary always evaluates to true.
756It prints the pathname of the current file to standard output.
757If none of
758.Ic -exec , -ls , -print0 ,
759or
760.Ic -ok
761is specified, the given expression shall be effectively replaced by
762.Cm \&( Ar "given expression" Cm \&) Ic -print .
763.It Ic -print0
764This primary always evaluates to true.
765It prints the pathname of the current file to standard output, followed by an
766.Tn ASCII
767.Dv NUL
768character (character code 0).
769.It Ic -prune
770This primary always evaluates to true.
771It causes
772.Nm
773to not descend into the current file.
774Note, the
775.Ic -prune
776primary has no effect if the
777.Fl d
778option was specified.
779.It Ic -quit
780Causes
781.Nm
782to terminate immediately.
783.It Ic -regex Ar pattern
784True if the whole path of the file matches
785.Ar pattern
786using regular expression.
787To match a file named
788.Dq Pa ./foo/xyzzy ,
789you can use the regular expression
790.Dq Li ".*/[xyz]*"
791or
792.Dq Li ".*/foo/.*" ,
793but not
794.Dq Li xyzzy
795or
796.Dq Li /foo/ .
797.It Ic -samefile Ar name
798True if the file is a hard link to
799.Ar name .
800If the command option
801.Ic -L
802is specified, it is also true if the file is a symbolic link and
803points to
804.Ar name .
805.It Ic -size Ar n Ns Op Cm ckMGTP
806True if the file's size, rounded up, in 512-byte blocks is
807.Ar n .
808If
809.Ar n
810is followed by a
811.Cm c ,
812then the primary is true if the
813file's size is
814.Ar n
815bytes (characters).
816Similarly if
817.Ar n
818is followed by a scale indicator then the file's size is compared to
819.Ar n
820scaled as:
821.Pp
822.Bl -tag -width indent -compact
823.It Cm k
824kilobytes (1024 bytes)
825.It Cm M
826megabytes (1024 kilobytes)
827.It Cm G
828gigabytes (1024 megabytes)
829.It Cm T
830terabytes (1024 gigabytes)
831.It Cm P
832petabytes (1024 terabytes)
833.El
834.It Ic -sparse
835True if the current file is sparse,
836i.e. has fewer blocks allocated than expected based on its size in bytes.
837This might also match files that have been compressed by the filesystem.
838.It Ic -type Ar t
839True if the file is of the specified type.
840Possible file types are as follows:
841.Pp
842.Bl -tag -width indent -compact
843.It Cm b
844block special
845.It Cm c
846character special
847.It Cm d
848directory
849.It Cm f
850regular file
851.It Cm l
852symbolic link
853.It Cm p
854FIFO
855.It Cm s
856socket
857.El
858.It Ic -uid Ar uname
859The same thing as
860.Ar -user Ar uname
861for compatibility with GNU find.
862GNU find imposes a restriction that
863.Ar uname
864is numeric, while
865.Nm
866does not.
867.It Ic -user Ar uname
868True if the file belongs to the user
869.Ar uname .
870If
871.Ar uname
872is numeric and there is no such user name, then
873.Ar uname
874is treated as a user ID.
875.It Ic -wholename Ar pattern
876The same thing as
877.Ic -path ,
878for GNU find compatibility.
879.El
880.Sh OPERATORS
881The primaries may be combined using the following operators.
882The operators are listed in order of decreasing precedence.
883.Pp
884.Bl -tag -width indent -compact
885.It Cm \&( Ar expression Cm \&)
886This evaluates to true if the parenthesized expression evaluates to
887true.
888.Pp
889.It Cm \&! Ar expression
890.It Cm -not Ar expression
891This is the unary
892.Tn NOT
893operator.
894It evaluates to true if the expression is false.
895.Pp
896.It Cm -false
897Always false.
898.It Cm -true
899Always true.
900.Pp
901.It Ar expression Cm -and Ar expression
902.It Ar expression expression
903The
904.Cm -and
905operator is the logical
906.Tn AND
907operator.
908As it is implied by the juxtaposition of two expressions it does not
909have to be specified.
910The expression evaluates to true if both expressions are true.
911The second expression is not evaluated if the first expression is false.
912.Pp
913.It Ar expression Cm -or Ar expression
914The
915.Cm -or
916operator is the logical
917.Tn OR
918operator.
919The expression evaluates to true if either the first or the second expression
920is true.
921The second expression is not evaluated if the first expression is true.
922.El
923.Pp
924All operands and primaries must be separate arguments to
925.Nm .
926Primaries which themselves take arguments expect each argument
927to be a separate argument to
928.Nm .
929.Sh ENVIRONMENT
930The
931.Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES
932and
933.Ev LC_TIME
934environment variables affect the execution of the
935.Nm
936utility as described in
937.Xr environ 7 .
938.Sh EXAMPLES
939The following examples are shown as given to the shell:
940.Bl -tag -width indent
941.It Li "find / \e! -name \*q*.c\*q -print"
942Print out a list of all the files whose names do not end in
943.Pa .c .
944.It Li "find / -newer ttt -user wnj -print"
945Print out a list of all the files owned by user
946.Dq wnj
947that are newer
948than the file
949.Pa ttt .
950.It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
951Print out a list of all the files which are not both newer than
952.Pa ttt
953and owned by
954.Dq wnj .
955.It Li "find / \e( -newer ttt -or -user wnj \e) -print"
956Print out a list of all the files that are either owned by
957.Dq wnj
958or that are newer than
959.Pa ttt .
960.It Li "find / -newerct '1 minute ago' -print"
961Print out a list of all the files whose inode change time is more
962recent than the current time minus one minute.
963.It Li "find / -type f -exec echo {} \e;"
964Use the
965.Xr echo 1
966command to print out a list of all the files.
967.It Li "find -L /usr/ports/packages -type l -exec rm -- {} +"
968Delete all broken symbolic links in
969.Pa /usr/ports/packages .
970.It Li "find /usr/src -name CVS -prune -o -depth +6 -print"
971Find files and directories that are at least seven levels deep
972in the working directory
973.Pa /usr/src .
974.It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print"
975Is not equivalent to the previous example, since
976.Ic -prune
977is not evaluated below level seven.
978.El
979.Sh COMPATIBILITY
980The
981.Ic -follow
982primary is deprecated; the
983.Fl L
984option should be used instead.
985See the
986.Sx STANDARDS
987section below for details.
988.Sh SEE ALSO
989.Xr chflags 1 ,
990.Xr chmod 1 ,
991.Xr cvs 1 ,
992.Xr locate 1 ,
993.Xr lsvfs 1 ,
994.Xr whereis 1 ,
995.Xr which 1 ,
996.Xr xargs 1 ,
997.Xr stat 2 ,
998.Xr acl 3 ,
999.Xr fts 3 ,
1000.Xr getgrent 3 ,
1001.Xr getpwent 3 ,
1002.Xr strmode 3 ,
1003.Xr re_format 7 ,
1004.Xr symlink 7
1005.Sh STANDARDS
1006The
1007.Nm
1008utility syntax is a superset of the syntax specified by the
1009.St -p1003.1-2001
1010standard.
1011.Pp
1012All the single character options except
1013.Fl H
1014and
1015.Fl L
1016as well as
1017.Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype ,
1018.Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin ,
1019.Ic -path , -print0 , -regex , -sparse
1020and all of the
1021.Ic -B*
1022birthtime related primaries are extensions to
1023.St -p1003.1-2001 .
1024.Pp
1025Historically, the
1026.Fl d , L
1027and
1028.Fl x
1029options were implemented using the primaries
1030.Ic -depth , -follow ,
1031and
1032.Ic -xdev .
1033These primaries always evaluated to true.
1034As they were really global variables that took effect before the traversal
1035began, some legal expressions could have unexpected results.
1036An example is the expression
1037.Ic -print Cm -o Ic -depth .
1038As
1039.Ic -print
1040always evaluates to true, the standard order of evaluation
1041implies that
1042.Ic -depth
1043would never be evaluated.
1044This is not the case.
1045.Pp
1046The operator
1047.Cm -or
1048was implemented as
1049.Cm -o ,
1050and the operator
1051.Cm -and
1052was implemented as
1053.Cm -a .
1054.Pp
1055Historic implementations of the
1056.Ic -exec
1057and
1058.Ic -ok
1059primaries did not replace the string
1060.Dq Li {}
1061in the utility name or the
1062utility arguments if it had preceding or following non-whitespace characters.
1063This version replaces it no matter where in the utility name or arguments
1064it appears.
1065.Pp
1066The
1067.Fl E
1068option was inspired by the equivalent
1069.Xr grep 1
1070and
1071.Xr sed 1
1072options.
1073.Sh HISTORY
1074A
1075.Nm
1076command appeared in
1077.At v1 .
1078.Sh BUGS
1079The special characters used by
1080.Nm
1081are also special characters to many shell programs.
1082In particular, the characters
1083.Dq Li * ,
1084.Dq Li \&[ ,
1085.Dq Li \&] ,
1086.Dq Li \&? ,
1087.Dq Li \&( ,
1088.Dq Li \&) ,
1089.Dq Li \&! ,
1090.Dq Li \e
1091and
1092.Dq Li \&;
1093may have to be escaped from the shell.
1094.Pp
1095As there is no delimiter separating options and file names or file
1096names and the
1097.Ar expression ,
1098it is difficult to specify files named
1099.Pa -xdev
1100or
1101.Pa \&! .
1102These problems are handled by the
1103.Fl f
1104option and the
1105.Xr getopt 3
1106.Dq Fl Fl
1107construct.
1108.Pp
1109The
1110.Ic -delete
1111primary does not interact well with other options that cause the file system
1112tree traversal options to be changed.
1113.Pp
1114The
1115.Ic -mindepth
1116and
1117.Ic -maxdepth
1118primaries are actually global options (as documented above).
1119They should
1120probably be replaced by options which look like options.
1121