xref: /freebsd/usr.bin/find/find.1 (revision 9168a75a66f08d0563d488667d26c7b8f5b6b2cb)
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 9, 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 -quit
745Causes
746.Nm
747to immediately terminate.
748.It Ic -regex Ar pattern
749True if the whole path of the file matches
750.Ar pattern
751using regular expression.
752To match a file named
753.Dq Pa ./foo/xyzzy ,
754you can use the regular expression
755.Dq Li ".*/[xyz]*"
756or
757.Dq Li ".*/foo/.*" ,
758but not
759.Dq Li xyzzy
760or
761.Dq Li /foo/ .
762.It Ic -samefile Ar name
763True if the file is a hard link to
764.Ar name .
765If the command option
766.Ic -L
767is specified, it is also true if the file is a symbolic link and
768points to
769.Ar name .
770.It Ic -size Ar n Ns Op Cm ckMGTP
771True if the file's size, rounded up, in 512-byte blocks is
772.Ar n .
773If
774.Ar n
775is followed by a
776.Cm c ,
777then the primary is true if the
778file's size is
779.Ar n
780bytes (characters).
781Similarly if
782.Ar n
783is followed by a scale indicator then the file's size is compared to
784.Ar n
785scaled as:
786.Pp
787.Bl -tag -width indent -compact
788.It Cm k
789kilobytes (1024 bytes)
790.It Cm M
791megabytes (1024 kilobytes)
792.It Cm G
793gigabytes (1024 megabytes)
794.It Cm T
795terabytes (1024 gigabytes)
796.It Cm P
797petabytes (1024 terabytes)
798.El
799.It Ic -type Ar t
800True if the file is of the specified type.
801Possible file types are as follows:
802.Pp
803.Bl -tag -width indent -compact
804.It Cm b
805block special
806.It Cm c
807character special
808.It Cm d
809directory
810.It Cm f
811regular file
812.It Cm l
813symbolic link
814.It Cm p
815FIFO
816.It Cm s
817socket
818.El
819.It Ic -uid Ar uname
820The same thing as
821.Ar -user Ar uname
822for compatibility with GNU find.
823GNU find imposes a restriction that
824.Ar uname
825is numeric, while
826.Xr find 1
827does not.
828.It Ic -user Ar uname
829True if the file belongs to the user
830.Ar uname .
831If
832.Ar uname
833is numeric and there is no such user name, then
834.Ar uname
835is treated as a user ID.
836.It Ic -wholename Ar pattern
837The same thing as
838.Ic -path ,
839for GNU find compatibility.
840.El
841.Sh OPERATORS
842The primaries may be combined using the following operators.
843The operators are listed in order of decreasing precedence.
844.Pp
845.Bl -tag -width indent -compact
846.It Cm \&( Ar expression Cm \&)
847This evaluates to true if the parenthesized expression evaluates to
848true.
849.Pp
850.It Cm \&! Ar expression
851.It Cm -not Ar expression
852This is the unary
853.Tn NOT
854operator.
855It evaluates to true if the expression is false.
856.Pp
857.It Cm -false
858Always false.
859.It Cm -true
860Always true.
861.Pp
862.It Ar expression Cm -and Ar expression
863.It Ar expression expression
864The
865.Cm -and
866operator is the logical
867.Tn AND
868operator.
869As it is implied by the juxtaposition of two expressions it does not
870have to be specified.
871The expression evaluates to true if both expressions are true.
872The second expression is not evaluated if the first expression is false.
873.Pp
874.It Ar expression Cm -or Ar expression
875The
876.Cm -or
877operator is the logical
878.Tn OR
879operator.
880The expression evaluates to true if either the first or the second expression
881is true.
882The second expression is not evaluated if the first expression is true.
883.El
884.Pp
885All operands and primaries must be separate arguments to
886.Nm .
887Primaries which themselves take arguments expect each argument
888to be a separate argument to
889.Nm .
890.Sh ENVIRONMENT
891The
892.Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES
893and
894.Ev LC_TIME
895environment variables affect the execution of the
896.Nm
897utility as described in
898.Xr environ 7 .
899.Sh EXAMPLES
900The following examples are shown as given to the shell:
901.Bl -tag -width indent
902.It Li "find / \e! -name \*q*.c\*q -print"
903Print out a list of all the files whose names do not end in
904.Pa .c .
905.It Li "find / -newer ttt -user wnj -print"
906Print out a list of all the files owned by user
907.Dq wnj
908that are newer
909than the file
910.Pa ttt .
911.It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
912Print out a list of all the files which are not both newer than
913.Pa ttt
914and owned by
915.Dq wnj .
916.It Li "find / \e( -newer ttt -or -user wnj \e) -print"
917Print out a list of all the files that are either owned by
918.Dq wnj
919or that are newer than
920.Pa ttt .
921.It Li "find / -newerct '1 minute ago' -print"
922Print out a list of all the files whose inode change time is more
923recent than the current time minus one minute.
924.It Li "find / -type f -exec echo {} \e;"
925Use the
926.Xr echo 1
927command to print out a list of all the files.
928.It Li "find -L /usr/ports/packages -type l -exec rm -- {} +"
929Delete all broken symbolic links in
930.Pa /usr/ports/packages .
931.It Li "find /usr/src -name CVS -prune -o -depth +6 -print"
932Find files and directories that are at least seven levels deep
933in the working directory
934.Pa /usr/src .
935.It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print"
936Is not equivalent to the previous example, since
937.Ic -prune
938is not evaluated below level seven.
939.El
940.Sh COMPATIBILITY
941The
942.Ic -follow
943primary is deprecated; the
944.Fl L
945option should be used instead.
946See the
947.Sx STANDARDS
948section below for details.
949.Sh SEE ALSO
950.Xr chflags 1 ,
951.Xr chmod 1 ,
952.Xr cvs 1 ,
953.Xr locate 1 ,
954.Xr lsvfs 1 ,
955.Xr whereis 1 ,
956.Xr which 1 ,
957.Xr xargs 1 ,
958.Xr stat 2 ,
959.Xr acl 3 ,
960.Xr fts 3 ,
961.Xr getgrent 3 ,
962.Xr getpwent 3 ,
963.Xr strmode 3 ,
964.Xr re_format 7 ,
965.Xr symlink 7
966.Sh STANDARDS
967The
968.Nm
969utility syntax is a superset of the syntax specified by the
970.St -p1003.1-2001
971standard.
972.Pp
973All the single character options except
974.Fl H
975and
976.Fl L
977as well as
978.Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype ,
979.Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin ,
980.Ic -path , -print0 , -regex
981and all of the
982.Ic -B*
983birthtime related primaries are extensions to
984.St -p1003.1-2001 .
985.Pp
986Historically, the
987.Fl d , L
988and
989.Fl x
990options were implemented using the primaries
991.Ic -depth , -follow ,
992and
993.Ic -xdev .
994These primaries always evaluated to true.
995As they were really global variables that took effect before the traversal
996began, some legal expressions could have unexpected results.
997An example is the expression
998.Ic -print Cm -o Ic -depth .
999As
1000.Ic -print
1001always evaluates to true, the standard order of evaluation
1002implies that
1003.Ic -depth
1004would never be evaluated.
1005This is not the case.
1006.Pp
1007The operator
1008.Cm -or
1009was implemented as
1010.Cm -o ,
1011and the operator
1012.Cm -and
1013was implemented as
1014.Cm -a .
1015.Pp
1016Historic implementations of the
1017.Ic -exec
1018and
1019.Ic -ok
1020primaries did not replace the string
1021.Dq Li {}
1022in the utility name or the
1023utility arguments if it had preceding or following non-whitespace characters.
1024This version replaces it no matter where in the utility name or arguments
1025it appears.
1026.Pp
1027The
1028.Fl E
1029option was inspired by the equivalent
1030.Xr grep 1
1031and
1032.Xr sed 1
1033options.
1034.Sh HISTORY
1035A
1036.Nm
1037command appeared in
1038.At v1 .
1039.Sh BUGS
1040The special characters used by
1041.Nm
1042are also special characters to many shell programs.
1043In particular, the characters
1044.Dq Li * ,
1045.Dq Li \&[ ,
1046.Dq Li \&] ,
1047.Dq Li \&? ,
1048.Dq Li \&( ,
1049.Dq Li \&) ,
1050.Dq Li \&! ,
1051.Dq Li \e
1052and
1053.Dq Li \&;
1054may have to be escaped from the shell.
1055.Pp
1056As there is no delimiter separating options and file names or file
1057names and the
1058.Ar expression ,
1059it is difficult to specify files named
1060.Pa -xdev
1061or
1062.Pa \&! .
1063These problems are handled by the
1064.Fl f
1065option and the
1066.Xr getopt 3
1067.Dq Fl Fl
1068construct.
1069.Pp
1070The
1071.Ic -delete
1072primary does not interact well with other options that cause the file system
1073tree traversal options to be changed.
1074.Pp
1075The
1076.Ic -mindepth
1077and
1078.Ic -maxdepth
1079primaries are actually global options (as documented above).
1080They should
1081probably be replaced by options which look like options.
1082