xref: /minix/usr.bin/find/find.1 (revision 0a6a1f1d)
1.\"	$NetBSD: find.1,v 1.81 2014/05/17 11:31:40 apb 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 May 17, 2014
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.Ar 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.Pp
174.Bl -tag -width Ds -compact
175.It Ic -amin Ar n
176True if the difference between the file last access time and the time
177.Nm
178was started, rounded up to the next full minute, is
179.Ar n
180minutes.
181.Pp
182.It Ic -anewer Ar file
183True if the current file has a more recent last access time than
184.Ar file .
185.Pp
186.It Ic -atime Ar n
187True if the difference between the file last access time and the time
188.Nm
189was started, rounded up to the next full 24-hour period, is
190.Ar n
19124-hour periods.
192.Pp
193.It Ic -cmin Ar n
194True if the difference between the time of last change of file status
195information and the time
196.Nm
197was started, rounded up to the next full minute, is
198.Ar n
199minutes.
200.Pp
201.It Ic -cnewer Ar file
202True if the current file has a more recent last change time than
203.Ar file .
204.Pp
205.It Ic -ctime Ar n
206True if the difference between the time of last change of file status
207information and the time
208.Nm
209was started, rounded up to the next full 24-hour period, is
210.Ar n
21124-hour periods.
212.Pp
213.It Ic -delete
214Delete found files, symbolic links, and directories.
215Always returns true.
216This executes from the current working directory as
217.Nm
218recurses down the tree.
219To avoid deleting unexpected files, it will ignore any filenames that
220.Xr fts 3
221returns that contain a
222.Dq /
223.Xr ( fts 3
224should not return such pathnames).
225Depth-first traversal processing is implied by this option.
226This primary can also be invoked as
227.Ic -rm .
228.Pp
229.It Ic -empty
230True if the current file or directory is empty.
231.Pp
232.It Ic -exec Ar utility Oo argument ... Oc Ic \&;
233.It Ic -exec Ar utility Oo argument ... Oc Ic {} Ic \&+
234Execute the specified
235.Ar utility
236with the specified arguments.
237.Pp
238The list of arguments for
239.Ar utility
240is terminated by a lone semicolon
241.Dq Ic \&;
242or plus
243.Dq Ic \&+
244character as a separate parameter.
245The command specified by
246.Ar utility
247will be executed with its current working directory being the directory
248from which
249.Nm
250was executed.
251.Pp
252If the list of arguments is terminated by a semicolon
253.Pq Dq Ic \&; ,
254then
255.Ar utility
256is invoked once per pathname.
257If
258the string
259.Dq Ic {}
260appears one or more times in the utility name or arguments,
261then it is replaced by the pathname of the current file
262(but it need not appear, in which case the pathname
263will not be passed to
264.Ar utility ) .
265The semicolon-terminated form of the
266.Ic -exec
267primary returns true if and only if
268.Ar utility
269exits with a zero exit status.
270Note that the semicolon will have to be escaped on the shell command line
271in order to be passed as a parameter.
272.Pp
273If the list of arguments is terminated by a plus sign
274.Pq Dq Ic \&+ ,
275then the pathnames for which the primary is evaluated are aggregated
276into sets, and
277.Ar utility
278will be invoked once per set, similar to
279.Xr xargs 1 .
280In this case the string
281.Dq Ic {}
282must appear, and must appear as the last item in the argument list,
283just before the
284.Dq Ic \&+
285parameter, and is replaced by the pathnames of the current set of files.
286Each set is limited to no more than 5,000 pathnames,
287and is also limited such that the total number of bytes in the argument
288list does not exceed
289.Dv ARG_MAX .
290The plus-terminated form of the
291.Ic -exec
292primary always returns true.
293If the plus-terminated form of the
294.Ic -exec
295primary results in any invocation of
296.Ar utility
297exiting with non-zero exit status, then
298.Nm
299will eventually exit with non-zero status as well,
300but this does not cause
301.Nm
302to exit early.
303.Pp
304.It Ic -execdir Ar utility Oo argument ... Oc Ic \&;
305The
306.Ic -execdir
307primary is similar to the semicolon-terminated
308.Pq Dq Ic \&;
309variant of the
310.Ic -exec
311primary, with the exception that
312.Ar utility
313will be executed from the directory that holds
314the current file.
315Only the base filename is substituted for the string
316.Dq Ic {} .
317Set aggregation
318.Pq Do Ic \&+ Dc termination
319is not supported.
320.Pp
321.It Ic -exit Op Ar status
322This primary causes
323.Nm
324to stop traversing the file system and exit immediately,
325with the specified numeric exit status.
326If the
327.Ar status
328value is not specified, then
329.Nm
330will exit with status zero.
331Note that any preceding primaries will be evaluated and acted upon
332before exiting.
333.Pp
334.It Ic -false
335This primary always evaluates to false.
336This can be used following a primary that caused the
337expression to be true to make the expression to be false.
338This can be useful after using a
339.Ic -fprint
340primary so it can continue to the next expression (using an
341.Cm -or
342operator, for example).
343.Pp
344.It Ic -flags Oo Fl Oc Ns Ar flags
345If
346.Ar flags
347are preceded by a dash
348.Pq Dq Ic \- ,
349this primary evaluates to true
350if at least all of the bits in
351.Ar flags
352are set in the file's flags bits.
353If
354.Ar flags
355are not preceded by a dash, this primary evaluates to true if
356the bits in
357.Ar flags
358exactly match the file's flags bits.
359If
360.Ar flags
361is
362.Dq none ,
363files with no flags bits set are matched.
364(See
365.Xr chflags 1
366for more information about file flags.)
367.Pp
368.It Ic -follow
369Follow symbolic links.
370.Pp
371.It Ic -fprint Ar filename
372This primary always evaluates to true.
373This creates
374.Ar filename
375or overwrites the file if it already exists.
376The file is created at startup.
377It writes the pathname of the current file to this file, followed
378by a newline character.
379The file will be empty if no files are matched.
380.Pp
381.It Ic -fstype Ar type
382True if the file is contained in a file system of type
383.Ar type .
384The
385.Xr sysctl 8
386command can be used to find out the types of file systems
387that are available on the system:
388.Bd -literal -offset indent
389sysctl vfs.generic.fstypes
390.Ed
391.Pp
392In addition, there are two pseudo-types,
393.Dq local
394and
395.Dq rdonly .
396The former matches any file system physically mounted on the system where
397the
398.Nm
399is being executed, and the latter matches any file system which is
400mounted read-only.
401.Pp
402.It Ic -group Ar gname
403True if the file belongs to the group
404.Ar gname .
405If
406.Ar gname
407is numeric and there is no such group name, then
408.Ar gname
409is treated as a group id.
410.Pp
411.It Ic -iname Ar pattern
412True if the last component of the pathname being examined matches
413.Ar pattern
414in a case-insensitive manner.
415Special shell pattern matching characters
416.Po
417.Dq \&[ ,
418.Dq \&] ,
419.Dq \&* ,
420and
421.Dq \&?
422.Pc
423may be used as part of
424.Ar pattern .
425These characters may be matched explicitly by escaping them with a
426backslash
427.Pq Dq \e .
428.Pp
429.It Ic -inum Ar n
430True if the file has inode number
431.Ar n .
432.Pp
433.It Ic -iregex Ar regexp
434True if the path name of the current file matches the case-insensitive
435basic regular expression
436.Pq see Xr re_format 7
437.Ar regexp .
438This is a match on the whole path, not a search for the regular expression
439within the path.
440.Pp
441.It Ic -links Ar n
442True if the file has
443.Ar n
444links.
445.Pp
446.It Ic -rm
447This primary is an alias for
448.Ic -delete .
449.Pp
450.It Ic -ls
451This primary always evaluates to true.
452The following information for the current file is written to standard output:
453its inode number, size in 512-byte blocks, file permissions, number of hard
454links, owner, group, size in bytes, last modification time, and pathname.
455If the file is a block or character special file, the major and minor numbers
456will be displayed instead of the size in bytes.
457If the file is a symbolic link, the pathname of the linked-to file will be
458displayed preceded by
459.Dq -\*[Gt] .
460The format is identical to that produced by
461.Dq ls -dgils .
462.Pp
463.It Ic -maxdepth Ar n
464True if the current search depth is less than or equal to what is specified in
465.Ar n .
466.Pp
467.It Ic -mindepth Ar n
468True if the current search depth is at least what is specified in
469.Ar n .
470.Pp
471.It Ic -mmin Ar n
472True if the difference between the file last modification time and the time
473.Nm
474was started, rounded up to the next full minute, is
475.Ar n
476minutes.
477.Pp
478.It Ic -mtime Ar n
479True if the difference between the file last modification time and the time
480.Nm
481was started, rounded up to the next full 24-hour period, is
482.Ar n
48324-hour periods.
484.Pp
485.It Ic -ok Ar utility Oo argument ... Oc Ic \&;
486The
487.Ic -ok
488primary is similar to the semicolon-terminated
489.Pq Dq \&;
490variant of the
491.Ic -exec
492primary, with the exception that
493.Nm
494requests user affirmation for the execution of
495.Ar utility
496by printing
497a message to the terminal and reading a response.
498If the response is other than
499.Dq y ,
500the command is not executed and the
501.Ic -ok
502primary evaluates to false.
503Set aggregation
504.Pq Do \&+ Dc termination
505is not supported.
506.Pp
507.It Ic -name Ar pattern
508True if the last component of the pathname being examined matches
509.Ar pattern .
510Special shell pattern matching characters
511.Po
512.Dq \&[ ,
513.Dq \&] ,
514.Dq \&* ,
515and
516.Dq \&?
517.Pc
518may be used as part of
519.Ar pattern .
520These characters may be matched explicitly by escaping them with a
521backslash
522.Pq Dq \e .
523.Pp
524.It Ic -newer Ar file
525True if the current file has a more recent last modification time than
526.Ar file .
527.Pp
528.It Ic -nouser
529True if the file belongs to an unknown user.
530.Pp
531.It Ic -nogroup
532True if the file belongs to an unknown group.
533.Pp
534.It Ic -path Ar pattern
535True if the pathname being examined matches
536.Ar pattern .
537Special shell pattern matching characters
538.Po
539.Dq \&[ ,
540.Dq \&] ,
541.Dq \&* ,
542and
543.Dq \&?
544.Pc
545may be used as part of
546.Ar pattern .
547These characters may be matched explicitly by escaping them with a
548backslash
549.Pq Dq \e .
550Slashes
551.Pq Dq /
552are treated as normal characters and do not have to be
553matched explicitly.
554.Pp
555.It Ic -perm Oo Fl Oc Ns Ar mode
556The
557.Ar mode
558may be either symbolic (see
559.Xr chmod 1 )
560or an octal number.
561If the mode is symbolic, a starting value of zero is assumed and the
562mode sets or clears permissions without regard to the process' file mode
563creation mask.
564If the mode is octal, only bits 07777
565.Pf ( Dv S_ISUID
566|
567.Dv S_ISGID
568|
569.Dv S_ISTXT
570|
571.Dv S_IRWXU
572|
573.Dv S_IRWXG
574|
575.Dv S_IRWXO )
576of the file's mode bits participate
577in the comparison.
578If the mode is preceded by a dash
579.Pq Dq Ic \- ,
580this primary evaluates to true
581if at least all of the bits in the mode are set in the file's mode bits.
582If the mode is not preceded by a dash, this primary evaluates to true if
583the bits in the mode exactly match the file's mode bits.
584Note, the first character of a symbolic mode may not be a dash
585.Pq Dq Ic \- .
586.Pp
587.It Ic -print
588This primary always evaluates to true.
589It prints the pathname of the current file to standard output, followed
590by a newline character.
591If none of
592.Ic -delete ,
593.Ic -exec ,
594.Ic -execdir ,
595.Ic -exit ,
596.Ic -fprint ,
597.Ic -ls ,
598.Ic -ok ,
599.Ic -print0 ,
600.Ic -printx ,
601nor
602.Ic -rm
603is specified, the given expression shall be effectively replaced by
604.Cm \&( Ns Ar given\& expression Ns Cm \&)
605.Ic -print .
606.Pp
607.It Ic -print0
608This primary always evaluates to true.
609It prints the pathname of the current file to standard output, followed
610by a NUL character.
611.Pp
612.It Ic -printx
613This primary always evaluates to true.
614It prints the pathname of the current file to standard output,
615with each space, tab, newline, backslash, dollar sign, and single,
616double, or back quotation mark prefixed by a backslash, so the output of
617.Nm
618can safely be used as input to
619.Xr xargs 1 .
620.Pp
621.It Ic -prune
622This primary always evaluates to true.
623It causes
624.Nm
625to not descend into the current file.
626Note, the
627.Ic -prune
628primary has no effect if the
629.Fl d
630option was specified.
631.Pp
632.It Ic -regex Ar regexp
633True if the path name of the current file matches the case-sensitive
634basic regular expression
635.Pq see Xr re_format 7
636.Ar regexp .
637This is a match on the whole path, not a search for the regular expression
638within the path.
639.Pp
640.It Ic -size Ar n Ns Op Cm c
641True if the file's size, rounded up, in 512-byte blocks is
642.Ar n .
643If
644.Ar n
645is followed by a
646.Dq Ic c ,
647then the primary is true if the file's size is
648.Ar n
649bytes.
650.Pp
651.It Ic -type Ar t
652True if the file is of the specified type.
653Possible file types are as follows:
654.Pp
655.Bl -tag -width flag -offset indent -compact
656.It Cm b
657block special
658.It Cm c
659character special
660.It Cm d
661directory
662.It Cm f
663regular file
664.It Cm l
665symbolic link
666.It Cm p
667FIFO
668.It Cm s
669socket
670.It Cm W
671whiteout
672.It Cm w
673whiteout
674.El
675.Pp
676.It Ic -user Ar uname
677True if the file belongs to the user
678.Ar uname .
679If
680.Ar uname
681is numeric and there is no such user name, then
682.Ar uname
683is treated as a user id (and considered a numeric argument).
684.Pp
685.It Ic -xdev
686This primary always evaluates to true.
687It causes find not to descend past directories that have a different
688device ID
689.Va ( st_dev ,
690see
691.Xr stat 2
692S5.6.2 [POSIX.1]).
693.El
694.Sh OPERATORS
695The primaries may be combined using the following operators.
696The operators are listed in order of decreasing precedence.
697.Bl -tag -width (expression)
698.It Cm \&( Ar expression Cm \&)
699This evaluates to true if the parenthesized expression evaluates to
700true.
701.It Cm \&! Ar expression
702This is the unary
703.Tn NOT
704operator.
705It evaluates to true if the expression is false.
706.It Ar expression Cm -and Ar expression
707.It Ar expression expression
708The
709.Cm -and
710operator is the logical
711.Tn AND
712operator.
713As it is implied by the juxtaposition of two expressions it does not
714have to be specified.
715The expression evaluates to true if both expressions are true.
716The second expression is not evaluated if the first expression is false.
717.It Ar expression Cm -or Ar expression
718The
719.Cm -or
720operator is the logical
721.Tn OR
722operator.
723The expression evaluates to true if either the first or the second expression
724is true.
725The second expression is not evaluated if the first expression is true.
726.El
727.Pp
728All operands and primaries must be separate arguments to
729.Nm .
730Primaries which themselves take arguments expect each argument
731to be a separate argument to
732.Nm .
733.Sh EXIT STATUS
734The
735.Nm
736utility normally exits 0 on success, and exits with 1 under certain
737internal error conditions.
738If any invocations of
739.Dq Ic -exec Ar ... Ic \&+
740primaries return non-zero exit-status, then
741.Nm
742will do so as well.
743.Sh EXAMPLES
744The following examples are shown as given to the shell:
745.Bl -tag -width findx
746.It Li "find / \e! -name \*q*.c\*q \-print"
747Print out a list of all the files whose names do not end in
748.Dq \&.c .
749.It Li "find / \-newer ttt \-user wnj \-print"
750Print out a list of all the files owned by user
751.Dq wnj
752that are newer than the file
753.Dq ttt .
754.It Li "find . \-type f \-mmin \-30 \-print \-or \-mindepth 1 \-prune"
755Print out a list of all the files in the current directory that are
756newer than 30 minutes.
757.It Li "find . \-type f \-atime +10 \-mindepth 2 \-print"
758Print out a list of all the files in any sub-directories that have not
759been accessed in the past ten days.
760.It Li "find . \-mtime +90 \-exec rm \-i {} + \-or \-mindepth 1 \-prune"
761Interactively remove all of the files in the current directory that have
762not been modified in 90 days.
763.It Li "find . \-type f \-mtime +90 \-ok mv {} {}.old \e;"
764Interactively rename all of the files in the current directory and all
765sub-directories that have not been modified in 90 days.
766.It Li "find / \e! \e( \-newer ttt \-user wnj \e) \-print"
767Print out a list of all the files which are not both newer than
768.Dq ttt
769and owned by
770.Dq wnj .
771.It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-print"
772Print out a list of all the files that are either owned by
773.Dq wnj
774or that are newer than
775.Dq ttt .
776.It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-exit 1"
777Return immediately with a value of 1 if any files are found that are either
778owned by
779.Dq wnj
780or that are newer than
781.Dq ttt ,
782but do not print them.
783.It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-ls \-exit 1"
784Same as above, but list the first file matching the criteria before exiting
785with a value of 1.
786.It Li "find . \-type f \-exec sh \-c 'file=\*[q]$1\*[q]; ...;' - {} \;"
787Perform an arbitrarily complex shell command for every file.
788.El
789.Sh SEE ALSO
790.Xr chflags 1 ,
791.Xr chmod 1 ,
792.Xr locate 1 ,
793.Xr xargs 1 ,
794.Xr stat 2 ,
795.Xr fts 3 ,
796.Xr getgrent 3 ,
797.Xr getpwent 3 ,
798.Xr strmode 3 ,
799.Xr re_format 7 ,
800.Xr symlink 7 ,
801.Xr sysctl 8
802.Sh STANDARDS
803The
804.Nm
805utility syntax is a superset of the syntax specified by the
806.St -p1003.2
807standard.
808.Pp
809The options and the
810.Ic -amin ,
811.Ic -anewer ,
812.Ic -cmin ,
813.Ic -cnewer ,
814.Ic -delete ,
815.Ic -empty ,
816.Ic -execdir ,
817.Ic -follow ,
818.Ic -fstype ,
819.Ic -iname ,
820.Ic -inum ,
821.Ic -iregex ,
822.Ic -links ,
823.Ic -ls ,
824.Ic -maxdepth ,
825.Ic -mindepth ,
826.Ic -mmin ,
827.Ic -path ,
828.Ic -print0 ,
829.Ic -printx ,
830.Ic -regex ,
831and
832.Ic -rm
833primaries are extensions to
834.St -p1003.2 .
835.Pp
836Historically, the
837.Fl d ,
838.Fl h ,
839and
840.Fl x
841options were implemented using the primaries
842.Dq Ic -depth ,
843.Dq Ic -follow ,
844and
845.Dq Ic -xdev .
846These primaries always evaluated to true, and always
847took effect when the
848.Ar expression
849was parsed, before the file system traversal began.
850As a result, some legal expressions could be confusing.
851For example, in the expression
852.Dq Ic -print Ic -or Ic -depth ,
853.Ic -print
854always evaluates to true, so the standard meaning of
855.Ic -or
856implies that
857.Ic -depth
858would never be evaluated, but that is not what happens;
859in fact,
860.Ic -depth
861takes effect immediately, without testing whether
862.Ic -print
863returns true or false.
864.Pp
865Historically, the operator
866.Dq Ic -or
867was implemented as
868.Dq Ic -o ,
869and the operator
870.Dq Ic -and
871was implemented as
872.Dq Ic -a .
873.Pp
874Historic implementations of the
875.Dq Ic -exec
876and
877.Dq Ic -ok
878primaries did not replace the string
879.Dq Ic {}
880in the utility name or the
881utility arguments if it did not appear as a separate argument.
882This version replaces it no matter where in the utility name or arguments
883it appears.
884.Pp
885Support for
886.Dq Ic -exec Ar ... Ic \&+
887is consistent with
888.Em IEEE PASC Interpretation 1003.2 #210 ,
889though the feature originated in
890.Tn SVR4 .
891.Pp
892The
893.Ic -delete
894primary does not interact well with other options that cause the file system
895tree traversal options to be changed.
896.Sh HISTORY
897A much simpler
898.Nm
899command appeared in First Edition AT\*[Am]T Unix.
900The syntax had become similar to the present version by
901the time of the Fifth Edition.
902.Sh BUGS
903The special characters used by
904.Nm
905are also special characters to many shell programs.
906In particular, the characters
907.Dq \&* ,
908.Dq \&[ ,
909.Dq \&] ,
910.Dq \&? ,
911.Dq \&( ,
912.Dq \&) ,
913.Dq \&! ,
914.Dq \e ,
915and
916.Dq \&;
917may have to be escaped from the shell.
918.Pp
919As there is no delimiter separating options and file names or file
920names and the
921.Ar expression ,
922it is difficult to specify files named
923.Dq -xdev
924or
925.Dq \&! .
926These problems are handled by the
927.Fl f
928option and the
929.Xr getopt 3
930.Dq --
931construct.
932