xref: /netbsd-src/usr.bin/find/find.1 (revision 796c32c94f6e154afc9de0f63da35c91bb739b45)
1.\"	$NetBSD: find.1,v 1.89 2017/07/03 21:34:57 wiz Exp $
2.\"
3.\" Copyright (c) 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" the Institute of Electrical and Electronics Engineers, Inc.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\"	from: @(#)find.1	8.7 (Berkeley) 5/9/95
34.\"
35.Dd June 13, 2016
36.Dt FIND 1
37.Os
38.Sh NAME
39.Nm find
40.Nd walk a file hierarchy
41.Sh SYNOPSIS
42.Nm
43.Op Fl H | Fl L | Fl P
44.Op Fl dEhsXx
45.Ar file
46.Op Ar file ...
47.Op Ar expression
48.Nm
49.Op Fl H | Fl L | Fl P
50.Op Fl dEhsXx
51.Fl f Ar file
52.Op Ar file ...
53.Op Ar expression
54.Sh DESCRIPTION
55.Nm
56recursively descends the directory tree for each
57.Ar file
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 Ds
69.It Fl H
70Causes the file information and file type (see
71.Xr stat 2 )
72returned for each symbolic link encountered on the command line to be
73those of the file referenced by the link, not the link itself.
74If the referenced file does not exist, the file information and type will
75be for the link itself.
76File information of all symbolic links not on the command line is that
77of the link itself.
78.It Fl L
79Causes the file information and file type (see
80.Xr stat 2 )
81returned for each symbolic link to be those of the file referenced by the
82link, not the link itself.
83If the referenced file does not exist, the file information and type will
84be for the link itself.
85.It Fl P
86Causes the file information and file type (see
87.Xr stat 2 )
88returned for each symbolic link to be those of the link itself.
89.It Fl d
90Causes
91.Nm
92to perform a depth-first traversal, i.e., directories
93are visited in post-order, and all entries in a directory will be acted
94on before the directory itself.
95By default,
96.Nm
97visits directories in pre-order, i.e., before their contents.
98Note, the default is
99.Em not
100a breadth-first traversal.
101.It Fl E
102Causes
103.Ar regexp
104arguments to primaries to be interpreted as extended regular
105expressions (see
106.Xr re_format 7 ) .
107.It Fl f
108Specifies a file hierarchy for
109.Nm
110to traverse.
111File hierarchies may also be specified as the operands immediately
112following the options.
113.It Fl h
114Causes the file information and file type (see
115.Xr stat 2 )
116returned for each symbolic link to be those of the file referenced by the
117link, not the link itself.
118If the referenced file does not exist, the file information and type will
119be for the link itself.
120.It Fl s
121Causes the entries of each directory to be sorted in
122lexicographical order.
123Note that the sorting is done only inside of each directory;
124files in different directories are not sorted.
125Therefore,
126.Sq Li a/b
127appears before
128.Sq Li a.b ,
129which is different from
130.Dq Li "find ... \&| sort"
131order.
132.It Fl X
133Modifies the output to permit
134.Nm
135to be safely used in conjunction with
136.Xr xargs 1 .
137If a file name contains any of the delimiting characters used by
138.Xr xargs 1 ,
139a diagnostic message is displayed on standard error, and the file
140is skipped.
141The delimiting characters include single
142.Pq Dq \&'
143and double
144.Pq Dq \&"
145quotes, backslash
146.Pq Dq \e ,
147space, tab, and newline characters.
148Alternatively, the
149.Ic -print0
150or
151.Ic -printx
152primaries can be used to format the output in a way that
153.Xr xargs 1
154can accept.
155.It Fl x
156Restricts the search to the file system containing the
157directory specified.
158Does not list mount points to other file systems.
159.El
160.Sh PRIMARIES
161All primaries which take a numeric argument of
162.Ar n
163allow the number to be preceded by a plus sign
164.Pq Dq \&+
165or a minus sign
166.Pq Dq \- .
167A preceding plus sign means
168.Dq more than Ar n ,
169a preceding minus sign means
170.Dq less than Ar n ,
171and neither means
172.Dq exactly Ar n .
173(The argument specified for the
174.Ic -user
175and
176.Ic -group
177primaries
178are similarly treated if the value is numeric and does not correspond to a
179valid user or group name.)
180.Pp
181For primaries which take a
182.Ar timestamp
183argument, the argument must be valid input to
184.Xr parsedate 3 .
185If the argument contains multiple words, enclose the argument in quotes.
186.Pp
187.Bl -tag -width Ds -compact
188.It Ic -amin Ar n
189True if the difference between the file last access time and the time
190.Nm
191was started, rounded up to the next full minute, is
192.Ar n
193minutes.
194.Pp
195.It Ic -anewer Ar file
196True if the current file has a more recent last access time than
197.Ar file .
198.Pp
199.It Ic -asince Ar timestamp
200True if the file last access time is greater than the specified
201.Ar timestamp .
202.Pp
203.It Ic -atime Ar n
204True if the difference between the file last access time and the time
205.Nm
206was started, rounded up to the next full 24-hour period, is
207.Ar n
20824-hour periods.
209.Pp
210.It Ic -cmin Ar n
211True if the difference between the time of last change of file status
212information and the time
213.Nm
214was started, rounded up to the next full minute, is
215.Ar n
216minutes.
217.Pp
218.It Ic -cnewer Ar file
219True if the current file has a more recent last change time than
220.Ar file .
221.Pp
222.It Ic -csince Ar timestamp
223True if the file last status change time is greater than the specified
224.Ar timestamp .
225.Pp
226.It Ic -ctime Ar n
227True if the difference between the time of last change of file status
228information and the time
229.Nm
230was started, rounded up to the next full 24-hour period, is
231.Ar n
23224-hour periods.
233.Pp
234.It Ic -delete
235Delete found files, symbolic links, and directories.
236Always returns true.
237This executes from the current working directory as
238.Nm
239recurses down the tree.
240To avoid deleting unexpected files, it will ignore any filenames that
241.Xr fts 3
242returns that contain a
243.Dq /
244.Xr ( fts 3
245should not return such pathnames).
246Depth-first traversal processing is implied by this option.
247This primary can also be invoked as
248.Ic -rm .
249.Pp
250.It Ic -empty
251True if the current file or directory is empty.
252.Pp
253.It Ic -exec Ar utility Oo argument ... Oc Ic \&;
254.It Ic -exec Ar utility Oo argument ... Oc Ic {} Ic \&+
255Execute the specified
256.Ar utility
257with the specified arguments.
258.Pp
259The list of arguments for
260.Ar utility
261is terminated by a lone semicolon
262.Dq Ic \&;
263or plus
264.Dq Ic \&+
265character as a separate parameter.
266The command specified by
267.Ar utility
268will be executed with its current working directory being the directory
269from which
270.Nm
271was executed.
272.Pp
273If the list of arguments is terminated by a semicolon
274.Pq Dq Ic \&; ,
275then
276.Ar utility
277is invoked once per pathname.
278If
279the string
280.Dq Ic {}
281appears one or more times in the utility name or arguments,
282then it is replaced by the pathname of the current file
283(but it need not appear, in which case the pathname
284will not be passed to
285.Ar utility ) .
286The semicolon-terminated form of the
287.Ic -exec
288primary returns true if and only if
289.Ar utility
290exits with a zero exit status.
291Note that the semicolon will have to be escaped on the shell command line
292in order to be passed as a parameter.
293.Pp
294If the list of arguments is terminated by a plus sign
295.Pq Dq Ic \&+ ,
296then the pathnames for which the primary is evaluated are aggregated
297into sets, and
298.Ar utility
299will be invoked once per set, similar to
300.Xr xargs 1 .
301In this case the string
302.Dq Ic {}
303must appear, and must appear as the last item in the argument list,
304just before the
305.Dq Ic \&+
306parameter, and is replaced by the pathnames of the current set of files.
307Each set is limited to no more than 5,000 pathnames,
308and is also limited such that the total number of bytes in the argument
309list does not exceed
310.Dv ARG_MAX .
311The plus-terminated form of the
312.Ic -exec
313primary always returns true.
314If the plus-terminated form of the
315.Ic -exec
316primary results in any invocation of
317.Ar utility
318exiting with non-zero exit status, then
319.Nm
320will eventually exit with non-zero status as well,
321but this does not cause
322.Nm
323to exit early.
324.Pp
325.It Ic -execdir Ar utility Oo argument ... Oc Ic \&;
326The
327.Ic -execdir
328primary is similar to the semicolon-terminated
329.Pq Dq Ic \&;
330variant of the
331.Ic -exec
332primary, with the exception that
333.Ar utility
334will be executed from the directory that holds
335the current file.
336Only the base filename is substituted for the string
337.Dq Ic {} .
338Set aggregation
339.Pq Do Ic \&+ Dc termination
340is not supported.
341.Pp
342.It Ic -exit Op Ar status
343This primary causes
344.Nm
345to stop traversing the file system and exit immediately,
346with the specified numeric exit status.
347If the
348.Ar status
349value is not specified, then
350.Nm
351will exit with status zero.
352Note that any preceding primaries will be evaluated and acted upon
353before exiting.
354.Pp
355.It Ic -false
356This primary always evaluates to false.
357This can be used following a primary that caused the
358expression to be true to make the expression to be false.
359This can be useful after using a
360.Ic -fprint
361primary so it can continue to the next expression (using an
362.Cm -or
363operator, for example).
364.Pp
365.It Ic -flags Oo Fl Oc Ns Ar flags
366If
367.Ar flags
368are preceded by a dash
369.Pq Dq Ic \- ,
370this primary evaluates to true
371if at least all of the bits in
372.Ar flags
373are set in the file's flags bits.
374If
375.Ar flags
376are not preceded by a dash, this primary evaluates to true if
377the bits in
378.Ar flags
379exactly match the file's flags bits.
380If
381.Ar flags
382is
383.Dq none ,
384files with no flags bits set are matched.
385(See
386.Xr chflags 1
387for more information about file flags.)
388.Pp
389.It Ic -follow
390Follow symbolic links.
391.Pp
392.It Ic -fprint Ar filename
393This primary always evaluates to true.
394This creates
395.Ar filename
396or overwrites the file if it already exists.
397The file is created at startup.
398It writes the pathname of the current file to this file, followed
399by a newline character.
400The file will be empty if no files are matched.
401.Pp
402.It Ic -fstype Ar type
403True if the file is contained in a file system of type
404.Ar type .
405The
406.Xr sysctl 8
407command can be used to find out the types of file systems
408that are available on the system:
409.Bd -literal -offset indent
410sysctl vfs.generic.fstypes
411.Ed
412.Pp
413In addition, there are two pseudo-types,
414.Dq local
415and
416.Dq rdonly .
417The former matches any file system physically mounted on the system where
418the
419.Nm
420is being executed, and the latter matches any file system which is
421mounted read-only.
422.Pp
423.It Ic -group Ar gname
424True if the file belongs to the group
425.Ar gname .
426If
427.Ar gname
428is numeric and there is no such group name, then
429.Ar gname
430is treated as a group id (and considered a numeric argument).
431.Pp
432.It Ic -iname Ar pattern
433True if the last component of the pathname being examined matches
434.Ar pattern
435in a case-insensitive manner.
436Special shell pattern matching characters
437.Po
438.Dq \&[ ,
439.Dq \&] ,
440.Dq \&* ,
441and
442.Dq \&?
443.Pc
444may be used as part of
445.Ar pattern .
446These characters may be matched explicitly by escaping them with a
447backslash
448.Pq Dq \e .
449.Pp
450.It Ic -inum Ar n
451True if the file has inode number
452.Ar n .
453.Pp
454.It Ic -iregex Ar regexp
455True if the path name of the current file matches the case-insensitive
456basic regular expression
457.Pq see Xr re_format 7
458.Ar regexp .
459This is a match on the whole path, not a search for the regular expression
460within the path.
461.Pp
462.It Ic -links Ar n
463True if the file has
464.Ar n
465links.
466.Pp
467.It Ic -rm
468This primary is an alias for
469.Ic -delete .
470.Pp
471.It Ic -ls
472This primary always evaluates to true.
473The following information for the current file is written to standard output:
474its inode number, size in 512-byte blocks, file permissions, number of hard
475links, owner, group, size in bytes, last modification time, and pathname.
476If the file is a block or character special file, the major and minor numbers
477will be displayed instead of the size in bytes.
478If the file is a symbolic link, the pathname of the linked-to file will be
479displayed preceded by
480.Dq -> .
481The format is identical to that produced by
482.Dq ls -dgils .
483.Pp
484.It Ic -maxdepth Ar depth
485True if the current search depth is less than or equal to what is specified in
486.Ar depth .
487.Pp
488.It Ic -mindepth Ar depth
489True if the current search depth is at least what is specified in
490.Ar depth .
491.Pp
492.It Ic -mmin Ar n
493True if the difference between the file last modification time and the time
494.Nm
495was started, rounded up to the next full minute, is
496.Ar n
497minutes.
498.Pp
499.It Ic -mtime Ar n
500True if the difference between the file last modification time and the time
501.Nm
502was started, rounded up to the next full 24-hour period, is
503.Ar n
50424-hour periods.
505.Pp
506.It Ic -ok Ar utility Oo argument ... Oc Ic \&;
507The
508.Ic -ok
509primary is similar to the semicolon-terminated
510.Pq Dq \&;
511variant of the
512.Ic -exec
513primary, with the exception that
514.Nm
515requests user affirmation for the execution of
516.Ar utility
517by printing
518a message to the terminal and reading a response.
519If the response is other than
520.Dq y ,
521the command is not executed and the
522.Ic -ok
523primary evaluates to false.
524Set aggregation
525.Pq Do \&+ Dc termination
526is not supported.
527.Pp
528.It Ic -name Ar pattern
529True if the last component of the pathname being examined matches
530.Ar pattern .
531Special shell pattern matching characters
532.Po
533.Dq \&[ ,
534.Dq \&] ,
535.Dq \&* ,
536and
537.Dq \&?
538.Pc
539may be used as part of
540.Ar pattern .
541These characters may be matched explicitly by escaping them with a
542backslash
543.Pq Dq \e .
544.Pp
545.It Ic -newer Ar file
546True if the current file has a more recent last modification time than
547.Ar file .
548.Pp
549.It Ic -newerXY Ar reference
550For compatibility with Gnu findutils.
551.Bl -column -offset indent ".Sy findutils" ".Sy equivalent"
552.It Sy findutils Ta Sy find
553.It Sy option Ta Sy equivalent
554.It -neweraa Ta -anewer
555.It -newerat Ta -asince
556.It -newercc Ta -cnewer
557.It -newerct Ta -csince
558.It -newermm Ta -newer
559.It -newermt Ta -since
560.El
561.Pp
562Other option variants from findutils are not implemented.
563.Pp
564.It Ic -nouser
565True if the file belongs to an unknown user.
566.Pp
567.It Ic -nogroup
568True if the file belongs to an unknown group.
569.Pp
570.It Ic -path Ar pattern
571True if the pathname being examined matches
572.Ar pattern .
573Special shell pattern matching characters
574.Po
575.Dq \&[ ,
576.Dq \&] ,
577.Dq \&* ,
578and
579.Dq \&?
580.Pc
581may be used as part of
582.Ar pattern .
583These characters may be matched explicitly by escaping them with a
584backslash
585.Pq Dq \e .
586Slashes
587.Pq Dq /
588are treated as normal characters and do not have to be
589matched explicitly.
590.Pp
591.It Ic -perm Oo Fl Oc Ns Ar mode
592The
593.Ar mode
594may be either symbolic (see
595.Xr chmod 1 )
596or an octal number.
597If the mode is symbolic, a starting value of zero is assumed and the
598mode sets or clears permissions without regard to the process' file mode
599creation mask.
600If the mode is octal, only bits 07777
601.Pf ( Dv S_ISUID
602|
603.Dv S_ISGID
604|
605.Dv S_ISTXT
606|
607.Dv S_IRWXU
608|
609.Dv S_IRWXG
610|
611.Dv S_IRWXO )
612of the file's mode bits participate
613in the comparison.
614If the mode is preceded by a dash
615.Pq Dq Ic \- ,
616this primary evaluates to true
617if at least all of the bits in the mode are set in the file's mode bits.
618If the mode is not preceded by a dash, this primary evaluates to true if
619the bits in the mode exactly match the file's mode bits.
620Note, the first character of a symbolic mode may not be a dash
621.Pq Dq Ic \- .
622.Pp
623.It Ic -print
624This primary always evaluates to true.
625It prints the pathname of the current file to standard output, followed
626by a newline character.
627If none of
628.Ic -delete ,
629.Ic -exec ,
630.Ic -execdir ,
631.Ic -exit ,
632.Ic -fprint ,
633.Ic -ls ,
634.Ic -ok ,
635.Ic -print0 ,
636.Ic -printx ,
637nor
638.Ic -rm
639is specified, the given expression shall be effectively replaced by
640.Cm \&( Ns Ar given\& expression Ns Cm \&)
641.Ic -print .
642.Pp
643.It Ic -print0
644This primary always evaluates to true.
645It prints the pathname of the current file to standard output, followed
646by a NUL character.
647.Pp
648.It Ic -printx
649This primary always evaluates to true.
650It prints the pathname of the current file to standard output,
651with each space, tab, newline, backslash, dollar sign, and single,
652double, or back quotation mark prefixed by a backslash, so the output of
653.Nm
654can safely be used as input to
655.Xr xargs 1 .
656.Pp
657.It Ic -prune
658This primary always evaluates to true.
659It causes
660.Nm
661to not descend into the current file.
662Note, the
663.Ic -prune
664primary has no effect if the
665.Fl d
666option was specified.
667.Pp
668.It Ic -regex Ar regexp
669True if the path name of the current file matches the case-sensitive
670basic regular expression
671.Pq see Xr re_format 7
672.Ar regexp .
673This is a match on the whole path, not a search for the regular expression
674within the path.
675.Pp
676.It Ic -since Ar timestamp
677True if the file last modification time is more recent than
678.Ar timestamp .
679.Pp
680.It Ic -size Ar n Ns Op Cm c
681True if the file's size, rounded up, in 512-byte blocks is
682.Ar n .
683If
684.Ar n
685is followed by a
686.Dq Ic c ,
687then the primary is true if the file's size is
688.Ar n
689bytes.
690.Pp
691.It Ic -type Ar t
692True if the file is of the specified type.
693Possible file types are as follows:
694.Pp
695.Bl -tag -width flag -offset indent -compact
696.It Cm b
697block special
698.It Cm c
699character special
700.It Cm d
701directory
702.It Cm f
703regular file
704.It Cm l
705symbolic link
706.It Cm p
707FIFO
708.It Cm s
709socket
710.It Cm W
711whiteout
712.It Cm w
713whiteout
714.El
715.Pp
716.It Ic -user Ar username
717True if the file belongs to the user
718.Ar username .
719If
720.Ar username
721is numeric and there is no such user on the system, then
722.Ar username
723is treated as a user id (and considered a numeric argument).
724.Pp
725.It Ic -xdev
726This primary always evaluates to true.
727It causes find not to descend past directories that have a different
728device ID
729.Va ( st_dev ,
730see
731.Xr stat 2
732S5.6.2 [POSIX.1]).
733.El
734.Sh OPERATORS
735The primaries may be combined using the following operators.
736The operators are listed in order of decreasing precedence.
737.Bl -tag -width (expression)
738.It Cm \&( Ar expression Cm \&)
739This evaluates to true if the parenthesized expression evaluates to
740true.
741.It Cm \&! Ar expression
742This is the unary
743.Tn NOT
744operator.
745It evaluates to true if the expression is false.
746.It Ar expression Cm -and Ar expression
747.It Ar expression expression
748The
749.Cm -and
750operator is the logical
751.Tn AND
752operator.
753As it is implied by the juxtaposition of two expressions it does not
754have to be specified.
755The expression evaluates to true if both expressions are true.
756The second expression is not evaluated if the first expression is false.
757.It Ar expression Cm -or Ar expression
758The
759.Cm -or
760operator is the logical
761.Tn OR
762operator.
763The expression evaluates to true if either the first or the second expression
764is true.
765The second expression is not evaluated if the first expression is true.
766.El
767.Pp
768All operands and primaries must be separate arguments to
769.Nm .
770Primaries which themselves take arguments expect each argument
771to be a separate argument to
772.Nm .
773.Sh EXIT STATUS
774The
775.Nm
776utility normally exits 0 on success, and exits with 1 under certain
777internal error conditions.
778If any invocations of
779.Dq Ic -exec Ar ... Ic \&+
780primaries return non-zero exit-status, then
781.Nm
782will do so as well.
783.Sh EXAMPLES
784The following examples are shown as given to the shell:
785.Bl -tag -width findx
786.It Li "find / \e! -name \*q*.c\*q \-print"
787Print out a list of all the files whose names do not end in
788.Dq \&.c .
789.It Li "find / \-newer ttt \-user wnj \-print"
790Print out a list of all the files owned by user
791.Dq wnj
792that are newer than the file
793.Dq ttt .
794.It Li "find . \-type f \-mmin \-30 \-print \-or \-mindepth 1 \-prune"
795Print out a list of all the files in the current directory that are
796newer than 30 minutes.
797.It Li "find . \-type f \-atime +10 \-mindepth 2 \-print"
798Print out a list of all the files in any sub-directories that have not
799been accessed in the past ten days.
800.It Li "find . \-mtime +90 \-exec rm \-i {} + \-or \-mindepth 1 \-prune"
801Interactively remove all of the files in the current directory that have
802not been modified in 90 days.
803.It Li "find . \-type f \-mtime +90 \-ok mv {} {}.old \e;"
804Interactively rename all of the files in the current directory and all
805sub-directories that have not been modified in 90 days.
806.It Li "find / \e! \e( \-newer ttt \-user wnj \e) \-print"
807Print out a list of all the files which are not both newer than
808.Dq ttt
809and owned by
810.Dq wnj .
811.It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-print"
812Print out a list of all the files that are either owned by
813.Dq wnj
814or that are newer than
815.Dq ttt .
816.It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-exit 1"
817Return immediately with a value of 1 if any files are found that are either
818owned by
819.Dq wnj
820or that are newer than
821.Dq ttt ,
822but do not print them.
823.It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-ls \-exit 1"
824Same as above, but list the first file matching the criteria before exiting
825with a value of 1.
826.It Li "find . \-type f \-exec sh \-c 'file=\*[q]$1\*[q]; ...;' - {} \;"
827Perform an arbitrarily complex shell command for every file.
828.El
829.Sh SEE ALSO
830.Xr chflags 1 ,
831.Xr chmod 1 ,
832.Xr locate 1 ,
833.Xr xargs 1 ,
834.Xr stat 2 ,
835.Xr fts 3 ,
836.Xr getgrent 3 ,
837.Xr getpwent 3 ,
838.Xr strmode 3 ,
839.Xr re_format 7 ,
840.Xr symlink 7 ,
841.Xr sysctl 8
842.Sh STANDARDS
843The
844.Nm
845utility syntax is a superset of the syntax specified by the
846.St -p1003.2
847standard.
848.Pp
849The options and the
850.Ic -amin ,
851.Ic -anewer ,
852.Ic -asince ,
853.Ic -cmin ,
854.Ic -cnewer ,
855.Ic -csince ,
856.Ic -delete ,
857.Ic -empty ,
858.Ic -execdir ,
859.Ic -follow ,
860.Ic -fstype ,
861.Ic -iname ,
862.Ic -inum ,
863.Ic -iregex ,
864.Ic -links ,
865.Ic -ls ,
866.Ic -maxdepth ,
867.Ic -mindepth ,
868.Ic -mmin ,
869.Ic -path ,
870.Ic -print0 ,
871.Ic -printx ,
872.Ic -regex ,
873.Ic -rm ,
874and
875.Ic -since
876primaries are extensions to
877.St -p1003.2 .
878.Pp
879Historically, the
880.Fl d ,
881.Fl h ,
882and
883.Fl x
884options were implemented using the primaries
885.Dq Ic -depth ,
886.Dq Ic -follow ,
887and
888.Dq Ic -xdev .
889These primaries always evaluated to true, and always
890took effect when the
891.Ar expression
892was parsed, before the file system traversal began.
893As a result, some legal expressions could be confusing.
894For example, in the expression
895.Dq Ic -print Ic -or Ic -depth ,
896.Ic -print
897always evaluates to true, so the standard meaning of
898.Ic -or
899implies that
900.Ic -depth
901would never be evaluated, but that is not what happens;
902in fact,
903.Ic -depth
904takes effect immediately, without testing whether
905.Ic -print
906returns true or false.
907.Pp
908Historically, the operator
909.Dq Ic -or
910was implemented as
911.Dq Ic -o ,
912and the operator
913.Dq Ic -and
914was implemented as
915.Dq Ic -a .
916.Pp
917Historic implementations of the
918.Dq Ic -exec
919and
920.Dq Ic -ok
921primaries did not replace the string
922.Dq Ic {}
923in the utility name or the
924utility arguments if it did not appear as a separate argument.
925This version replaces it no matter where in the utility name or arguments
926it appears.
927.Pp
928Support for
929.Dq Ic -exec Ar ... Ic \&+
930is consistent with
931.Em IEEE PASC Interpretation 1003.2 #210 ,
932though the feature originated in
933.Tn SVR4 .
934.Pp
935The
936.Ic -delete
937primary does not interact well with other options that cause the file system
938tree traversal options to be changed.
939.Sh HISTORY
940A much simpler
941.Nm
942command appeared in First Edition AT&T Unix.
943The syntax had become similar to the present version by
944the time of the Fifth Edition.
945.Sh BUGS
946The special characters used by
947.Nm
948are also special characters to many shell programs.
949In particular, the characters
950.Dq \&* ,
951.Dq \&[ ,
952.Dq \&] ,
953.Dq \&? ,
954.Dq \&( ,
955.Dq \&) ,
956.Dq \&! ,
957.Dq \e ,
958and
959.Dq \&;
960may have to be escaped from the shell.
961.Pp
962As there is no delimiter separating options and file names or file
963names and the
964.Ar expression ,
965it is difficult to specify files named
966.Dq -xdev
967or
968.Dq \&! .
969These problems are handled by the
970.Fl f
971option and the
972.Xr getopt 3
973.Dq --
974construct.
975