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