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