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