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