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