xref: /freebsd/usr.bin/find/find.1 (revision 19261079b74319502c6ffa1249920079f0f69a72)
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 May 13, 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
663.Xr cvs 1 .
664Note that
665.Ic -newermm
666is equivalent to
667.Ic -newer .
668.It Ic -nogroup
669True if the file belongs to an unknown group.
670.It Ic -noignore_readdir_race
671Turn off the effect of
672.Ic -ignore_readdir_race .
673This is default behaviour.
674.It Ic -noleaf
675This option is for GNU find compatibility.
676In GNU find it disables an optimization not relevant to
677.Nm ,
678so it is ignored.
679.It Ic -nouser
680True if the file belongs to an unknown user.
681.It Ic -ok Ar utility Oo Ar argument ... Oc Li \&;
682The
683.Ic -ok
684primary is identical to the
685.Ic -exec
686primary with the exception that
687.Nm
688requests user affirmation for the execution of the
689.Ar utility
690by printing
691a message to the terminal and reading a response.
692If the response is not affirmative
693.Ql ( y
694in the
695.Dq Li POSIX
696locale),
697the command is not executed and the
698value of the
699.Ic -ok
700expression is false.
701.It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&;
702The
703.Ic -okdir
704primary is identical to the
705.Ic -execdir
706primary with the same exception as described for the
707.Ic -ok
708primary.
709.It Ic -path Ar pattern
710True if the pathname being examined matches
711.Ar pattern .
712Special shell pattern matching characters
713.Dq ( Li \&[ ,
714.Dq Li \&] ,
715.Dq Li * ,
716and
717.Dq Li \&? )
718may be used as part of
719.Ar pattern .
720These characters may be matched explicitly by escaping them with a
721backslash
722.Pq Dq Li \e .
723Slashes
724.Pq Dq Li /
725are treated as normal characters and do not have to be
726matched explicitly.
727.It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode
728The
729.Ar mode
730may be either symbolic (see
731.Xr chmod 1 )
732or an octal number.
733If the
734.Ar mode
735is symbolic, a starting value of zero is assumed and the
736.Ar mode
737sets or clears permissions without regard to the process' file mode
738creation mask.
739If the
740.Ar mode
741is octal, only bits 07777
742.Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
743of the file's mode bits participate
744in the comparison.
745If the
746.Ar mode
747is preceded by a dash
748.Pq Dq Li - ,
749this primary evaluates to true
750if at least all of the bits in the
751.Ar mode
752are set in the file's mode bits.
753If the
754.Ar mode
755is preceded by a plus
756.Pq Dq Li + ,
757this primary evaluates to true
758if any of the bits in the
759.Ar mode
760are set in the file's mode bits.
761Otherwise, this primary evaluates to true if
762the bits in the
763.Ar mode
764exactly match the file's mode bits.
765Note, the first character of a symbolic mode may not be a dash
766.Pq Dq Li - .
767.It Ic -print
768This primary always evaluates to true.
769It prints the pathname of the current file to standard output.
770If none of
771.Ic -exec , -ls , -print0 ,
772or
773.Ic -ok
774is specified, the given expression shall be effectively replaced by
775.Cm \&( Ar "given expression" Cm \&) Ic -print .
776.It Ic -print0
777This primary always evaluates to true.
778It prints the pathname of the current file to standard output, followed by an
779.Tn ASCII
780.Dv NUL
781character (character code 0).
782.It Ic -prune
783This primary always evaluates to true.
784It causes
785.Nm
786to not descend into the current file.
787Note, the
788.Ic -prune
789primary has no effect if the
790.Fl d
791option was specified.
792.It Ic -quit
793Causes
794.Nm
795to terminate immediately.
796.It Ic -regex Ar pattern
797True if the whole path of the file matches
798.Ar pattern
799using regular expression.
800To match a file named
801.Dq Pa ./foo/xyzzy ,
802you can use the regular expression
803.Dq Li ".*/[xyz]*"
804or
805.Dq Li ".*/foo/.*" ,
806but not
807.Dq Li xyzzy
808or
809.Dq Li /foo/ .
810.It Ic -samefile Ar name
811True if the file is a hard link to
812.Ar name .
813If the command option
814.Ic -L
815is specified, it is also true if the file is a symbolic link and
816points to
817.Ar name .
818.It Ic -size Ar n Ns Op Cm ckMGTP
819True if the file's size, rounded up, in 512-byte blocks is
820.Ar n .
821If
822.Ar n
823is followed by a
824.Cm c ,
825then the primary is true if the
826file's size is
827.Ar n
828bytes (characters).
829Similarly if
830.Ar n
831is followed by a scale indicator then the file's size is compared to
832.Ar n
833scaled as:
834.Pp
835.Bl -tag -width indent -compact
836.It Cm k
837kilobytes (1024 bytes)
838.It Cm M
839megabytes (1024 kilobytes)
840.It Cm G
841gigabytes (1024 megabytes)
842.It Cm T
843terabytes (1024 gigabytes)
844.It Cm P
845petabytes (1024 terabytes)
846.El
847.It Ic -sparse
848True if the current file is sparse,
849i.e. has fewer blocks allocated than expected based on its size in bytes.
850This might also match files that have been compressed by the filesystem.
851.It Ic -type Ar t
852True if the file is of the specified type.
853Possible file types are as follows:
854.Pp
855.Bl -tag -width indent -compact
856.It Cm b
857block special
858.It Cm c
859character special
860.It Cm d
861directory
862.It Cm f
863regular file
864.It Cm l
865symbolic link
866.It Cm p
867FIFO
868.It Cm s
869socket
870.El
871.It Ic -uid Ar uname
872The same thing as
873.Ar -user Ar uname
874for compatibility with GNU find.
875GNU find imposes a restriction that
876.Ar uname
877is numeric, while
878.Nm
879does not.
880.It Ic -user Ar uname
881True if the file belongs to the user
882.Ar uname .
883If
884.Ar uname
885is numeric and there is no such user name, then
886.Ar uname
887is treated as a user ID.
888.It Ic -wholename Ar pattern
889The same thing as
890.Ic -path ,
891for GNU find compatibility.
892.El
893.Sh OPERATORS
894The primaries may be combined using the following operators.
895The operators are listed in order of decreasing precedence.
896.Pp
897.Bl -tag -width indent -compact
898.It Cm \&( Ar expression Cm \&)
899This evaluates to true if the parenthesized expression evaluates to
900true.
901.Pp
902.It Cm \&! Ar expression
903.It Cm -not Ar expression
904This is the unary
905.Tn NOT
906operator.
907It evaluates to true if the expression is false.
908.Pp
909.It Cm -false
910Always false.
911.It Cm -true
912Always true.
913.Pp
914.It Ar expression Cm -and Ar expression
915.It Ar expression expression
916The
917.Cm -and
918operator is the logical
919.Tn AND
920operator.
921As it is implied by the juxtaposition of two expressions it does not
922have to be specified.
923The expression evaluates to true if both expressions are true.
924The second expression is not evaluated if the first expression is false.
925.Pp
926.It Ar expression Cm -or Ar expression
927The
928.Cm -or
929operator is the logical
930.Tn OR
931operator.
932The expression evaluates to true if either the first or the second expression
933is true.
934The second expression is not evaluated if the first expression is true.
935.El
936.Pp
937All operands and primaries must be separate arguments to
938.Nm .
939Primaries which themselves take arguments expect each argument
940to be a separate argument to
941.Nm .
942.Sh ENVIRONMENT
943The
944.Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES
945and
946.Ev LC_TIME
947environment variables affect the execution of the
948.Nm
949utility as described in
950.Xr environ 7 .
951.Sh EXAMPLES
952The following examples are shown as given to the shell:
953.Bl -tag -width indent
954.It Li "find / \e! -name \*q*.c\*q -print"
955Print out a list of all the files whose names do not end in
956.Pa .c .
957.It Li "find / -newer ttt -user wnj -print"
958Print out a list of all the files owned by user
959.Dq wnj
960that are newer
961than the file
962.Pa ttt .
963.It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
964Print out a list of all the files which are not both newer than
965.Pa ttt
966and owned by
967.Dq wnj .
968.It Li "find / \e( -newer ttt -or -user wnj \e) -print"
969Print out a list of all the files that are either owned by
970.Dq wnj
971or that are newer than
972.Pa ttt .
973.It Li "find / -newerct '1 minute ago' -print"
974Print out a list of all the files whose inode change time is more
975recent than the current time minus one minute.
976.It Li "find / -type f -exec echo {} \e;"
977Use the
978.Xr echo 1
979command to print out a list of all the files.
980.It Li "find -L /usr/ports/packages -type l -exec rm -- {} +"
981Delete all broken symbolic links in
982.Pa /usr/ports/packages .
983.It Li "find /usr/src -name CVS -prune -o -depth +6 -print"
984Find files and directories that are at least seven levels deep
985in the working directory
986.Pa /usr/src .
987.It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print"
988Is not equivalent to the previous example, since
989.Ic -prune
990is not evaluated below level seven.
991.El
992.Sh COMPATIBILITY
993The
994.Ic -follow
995primary is deprecated; the
996.Fl L
997option should be used instead.
998See the
999.Sx STANDARDS
1000section below for details.
1001.Sh SEE ALSO
1002.Xr chflags 1 ,
1003.Xr chmod 1 ,
1004.Xr cvs 1 ,
1005.Xr locate 1 ,
1006.Xr lsvfs 1 ,
1007.Xr whereis 1 ,
1008.Xr which 1 ,
1009.Xr xargs 1 ,
1010.Xr stat 2 ,
1011.Xr acl 3 ,
1012.Xr fts 3 ,
1013.Xr getgrent 3 ,
1014.Xr getpwent 3 ,
1015.Xr strmode 3 ,
1016.Xr re_format 7 ,
1017.Xr symlink 7
1018.Sh STANDARDS
1019The
1020.Nm
1021utility syntax is a superset of the syntax specified by the
1022.St -p1003.1-2001
1023standard.
1024.Pp
1025All the single character options except
1026.Fl H
1027and
1028.Fl L
1029as well as
1030.Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype ,
1031.Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin ,
1032.Ic -not , -path , -print0 , -regex , -sparse
1033and all of the
1034.Fl B*
1035birthtime related primaries are extensions to
1036.St -p1003.1-2001 .
1037.Pp
1038Historically, the
1039.Fl d , L
1040and
1041.Fl x
1042options were implemented using the primaries
1043.Ic -depth , -follow ,
1044and
1045.Ic -xdev .
1046These primaries always evaluated to true.
1047As they were really global variables that took effect before the traversal
1048began, some legal expressions could have unexpected results.
1049An example is the expression
1050.Ic -print Cm -o Ic -depth .
1051As
1052.Ic -print
1053always evaluates to true, the standard order of evaluation
1054implies that
1055.Ic -depth
1056would never be evaluated.
1057This is not the case.
1058.Pp
1059The operator
1060.Cm -or
1061was implemented as
1062.Cm -o ,
1063and the operator
1064.Cm -and
1065was implemented as
1066.Cm -a .
1067.Pp
1068Historic implementations of the
1069.Ic -exec
1070and
1071.Ic -ok
1072primaries did not replace the string
1073.Dq Li {}
1074in the utility name or the
1075utility arguments if it had preceding or following non-whitespace characters.
1076This version replaces it no matter where in the utility name or arguments
1077it appears.
1078.Pp
1079The
1080.Fl E
1081option was inspired by the equivalent
1082.Xr grep 1
1083and
1084.Xr sed 1
1085options.
1086.Sh HISTORY
1087A simple
1088.Nm
1089command appeared in
1090.At v1
1091and was removed in
1092.At v3 .
1093It was rewritten for
1094.At v5
1095and later be enhanced for the Programmer's Workbench (PWB).
1096These changes were later incorporated in
1097.At v7.
1098.Sh BUGS
1099The special characters used by
1100.Nm
1101are also special characters to many shell programs.
1102In particular, the characters
1103.Dq Li * ,
1104.Dq Li \&[ ,
1105.Dq Li \&] ,
1106.Dq Li \&? ,
1107.Dq Li \&( ,
1108.Dq Li \&) ,
1109.Dq Li \&! ,
1110.Dq Li \e
1111and
1112.Dq Li \&;
1113may have to be escaped from the shell.
1114.Pp
1115As there is no delimiter separating options and file names or file
1116names and the
1117.Ar expression ,
1118it is difficult to specify files named
1119.Pa -xdev
1120or
1121.Pa \&! .
1122These problems are handled by the
1123.Fl f
1124option and the
1125.Xr getopt 3
1126.Dq Fl Fl
1127construct.
1128.Pp
1129The
1130.Ic -delete
1131primary does not interact well with other options that cause the file system
1132tree traversal options to be changed.
1133.Pp
1134The
1135.Ic -mindepth
1136and
1137.Ic -maxdepth
1138primaries are actually global options (as documented above).
1139They should
1140probably be replaced by options which look like options.
1141