Annotation of src/usr.bin/find/find.1, Revision 1.94
1.94 ! tb 1: .\" $OpenBSD: find.1,v 1.93 2017/01/03 22:19:31 jmc Exp $
1.1 deraadt 2: .\" Copyright (c) 1990, 1993
3: .\" The Regents of the University of California. All rights reserved.
4: .\"
5: .\" This code is derived from software contributed to Berkeley by
6: .\" the Institute of Electrical and Electronics Engineers, Inc.
7: .\"
8: .\" Redistribution and use in source and binary forms, with or without
9: .\" modification, are permitted provided that the following conditions
10: .\" are met:
11: .\" 1. Redistributions of source code must retain the above copyright
12: .\" notice, this list of conditions and the following disclaimer.
13: .\" 2. Redistributions in binary form must reproduce the above copyright
14: .\" notice, this list of conditions and the following disclaimer in the
15: .\" documentation and/or other materials provided with the distribution.
1.38 millert 16: .\" 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: .\" may be used to endorse or promote products derived from this software
18: .\" without specific prior written permission.
19: .\"
20: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: .\" SUCH DAMAGE.
31: .\"
32: .\" from: @(#)find.1 8.1 (Berkeley) 6/6/93
33: .\"
1.93 jmc 34: .Dd $Mdocdate: January 3 2017 $
1.1 deraadt 35: .Dt FIND 1
36: .Os
37: .Sh NAME
38: .Nm find
39: .Nd walk a file hierarchy
40: .Sh SYNOPSIS
41: .Nm find
1.48 millert 42: .Op Fl dHhLXx
1.43 jaredy 43: .Op Fl f Ar path
1.91 schwarze 44: .Ar path ...
1.34 deraadt 45: .Op Ar expression
1.1 deraadt 46: .Sh DESCRIPTION
1.22 aaron 47: .Nm
1.1 deraadt 48: recursively descends the directory tree for each
1.43 jaredy 49: .Ar path
1.1 deraadt 50: listed, evaluating an
51: .Ar expression
1.22 aaron 52: (composed of the
53: .Dq primaries
54: and
1.52 otto 55: .Dq operators
1.22 aaron 56: listed below) in terms
1.12 millert 57: of each file in the tree.
1.34 deraadt 58: In the absence of an expression,
59: .Ic -print
60: is assumed.
1.66 jmc 61: If an expression is given,
62: but none of the primaries
1.94 ! tb 63: .Ic -delete ,
1.66 jmc 64: .Ic -exec ,
1.94 ! tb 65: .Ic -execdir ,
1.66 jmc 66: .Ic -ls ,
67: .Ic -ok ,
68: .Ic -print ,
69: or
70: .Ic -print0
1.67 jmc 71: are specified, the given expression is effectively replaced by
1.66 jmc 72: .Cm \&( Ar given expression Cm \&)
73: .Ic -print .
1.1 deraadt 74: .Pp
75: The options are as follows:
76: .Bl -tag -width Ds
77: .It Fl d
1.16 aaron 78: Causes
1.22 aaron 79: .Nm
1.45 jmc 80: to visit directories in post-order
81: i.e. all entries in a directory will be acted on before the directory itself.
1.1 deraadt 82: By default,
1.22 aaron 83: .Nm
1.45 jmc 84: visits directories in pre-order i.e. before their contents.
1.43 jaredy 85: .It Fl f Ar path
1.16 aaron 86: Specifies a file hierarchy for
1.22 aaron 87: .Nm
1.1 deraadt 88: to traverse.
1.52 otto 89: File hierarchies may be specified without the
90: .Fl f
91: option if they are given immediately after any other options.
1.35 millert 92: .It Fl H
93: Causes the file information and file type (see
94: .Xr stat 2 )
95: returned for each symbolic link encountered on the command line to be
96: those of the file referenced by the link, not the link itself.
97: If the referenced file does not exist, the file information and type will
98: be for the link itself.
99: File information of all symbolic links not on
100: the command line is that of the link itself.
1.1 deraadt 101: .It Fl h
1.35 millert 102: An alias for the
103: .Fl L
104: option.
1.37 david 105: This option exists for backwards compatibility.
1.35 millert 106: .It Fl L
1.16 aaron 107: Causes the file information and file type (see
1.22 aaron 108: .Xr stat 2 )
1.1 deraadt 109: returned for each symbolic link to be those of the file referenced by the
110: link, not the link itself.
111: If the referenced file does not exist, the file information and type will
112: be for the link itself.
113: .It Fl X
1.16 aaron 114: Permit
1.1 deraadt 115: .Nm
116: to be safely used in conjunction with
117: .Xr xargs 1 .
1.87 schwarze 118: If a file name contains any of the delimiting characters used by xargs,
1.1 deraadt 119: a diagnostic message is displayed on standard error, and the file
120: is skipped.
1.22 aaron 121: The delimiting characters include single
122: .Pq Ql '
123: and double
124: .Pq Ql \&"
125: quotes, backslash
126: .Pq Ql \e ,
127: space, tab, and newline
128: .Pq Sq \en
129: characters.
1.79 schwarze 130: Consider using
1.4 deraadt 131: .Fl print0
1.79 schwarze 132: instead.
1.1 deraadt 133: .It Fl x
1.16 aaron 134: Prevents
1.22 aaron 135: .Nm
1.1 deraadt 136: from descending into directories that have a device number different
137: than that of the file from which the descent began.
138: .El
1.76 schwarze 139: .Pp
140: It is not an error to specify more than one of
141: the mutually exclusive options
142: .Fl H
143: and
144: .Fl L .
145: Where more than one of these options is specified,
146: the last option given overrides the others.
1.1 deraadt 147: .Sh PRIMARIES
1.84 jmc 148: .Bl -tag -width Ds -compact
1.22 aaron 149: .It Ic -amin Ar n
1.15 deraadt 150: True if the difference between the file last access time and the time
1.22 aaron 151: .Nm
1.20 aaron 152: was started, rounded up to the next full minute, is
1.15 deraadt 153: .Ar n
1.20 aaron 154: minutes.
1.84 jmc 155: .Pp
1.24 millert 156: .It Ic -anewer Ar file
157: True if the current file has a more recent last access time than
1.25 aaron 158: .Ar file .
1.84 jmc 159: .Pp
1.22 aaron 160: .It Ic -atime Ar n
1.1 deraadt 161: True if the difference between the file last access time and the time
1.22 aaron 162: .Nm
163: was started, rounded up to the next full 24-hour period, is
1.1 deraadt 164: .Ar n
1.22 aaron 165: 24-hour periods.
1.84 jmc 166: .Pp
1.22 aaron 167: .It Ic -cmin Ar n
1.15 deraadt 168: True if the difference between the time of last change of file status
169: information and the time
1.22 aaron 170: .Nm
1.20 aaron 171: was started, rounded up to the next full minute, is
1.15 deraadt 172: .Ar n
1.20 aaron 173: minutes.
1.84 jmc 174: .Pp
1.24 millert 175: .It Ic -cnewer Ar file
176: True if the current file has a more recent last change time than
1.25 aaron 177: .Ar file .
1.84 jmc 178: .Pp
1.22 aaron 179: .It Ic -ctime Ar n
1.1 deraadt 180: True if the difference between the time of last change of file status
181: information and the time
1.22 aaron 182: .Nm
183: was started, rounded up to the next full 24-hour period, is
1.1 deraadt 184: .Ar n
1.22 aaron 185: 24-hour periods.
1.84 jmc 186: .Pp
1.92 tedu 187: .It Ic -delete
1.93 jmc 188: Delete found files and directories.
1.92 tedu 189: Always returns true.
190: This executes
191: from the current working directory as
192: .Nm
193: recurses down the tree.
194: It will not attempt to delete a filename with a
1.93 jmc 195: .Sq Pa /
1.92 tedu 196: character in its pathname relative to
1.93 jmc 197: .Sq Pa \&.
1.92 tedu 198: for security reasons.
199: Depth-first traversal processing is implied by this option.
200: The
201: .Ic -delete
202: primary will fail to delete a directory if it is not empty.
203: Following symlinks is incompatible with this option.
1.93 jmc 204: .Pp
1.56 jmc 205: .It Ic -depth
1.61 jmc 206: This primary always evaluates to true.
1.56 jmc 207: The same as specifying the
208: .Fl d
209: option.
1.84 jmc 210: .Pp
1.8 tholo 211: .It Ic -empty
212: True if the current file or directory is empty.
1.84 jmc 213: .Pp
1.89 jmc 214: .It Ic -exec Ar utility Oo Ar argument ... Oc \&;
215: .It Ic -exec Ar utility Oo Ar argument ... Oc {} +
1.83 pascal 216: Execute the specified
217: .Ar utility .
1.1 deraadt 218: Optional arguments may be passed to the utility.
1.22 aaron 219: The expression must be terminated by a semicolon
1.83 pascal 220: .Pq Ql \&;
221: or a plus sign
222: .Pq Ql \&+ .
223: .Pp
224: If terminated by a semicolon, the
225: .Ar utility
226: is executed once per path.
1.22 aaron 227: If the string
228: .Qq {}
229: appears anywhere in the utility name or the
1.1 deraadt 230: arguments it is replaced by the pathname of the current file.
1.83 pascal 231: .Pp
1.84 jmc 232: If terminated by a plus sign,
1.83 pascal 233: the pathnames for which the
234: primary is evaluated are aggregated into sets, and
1.16 aaron 235: .Ar utility
1.83 pascal 236: will be invoked once per set, similar to
237: .Xr xargs 1 .
1.84 jmc 238: If any invocation exits with a non-zero exit status, then
1.83 pascal 239: .Nm
240: will eventually do so as well, but this does not cause
1.22 aaron 241: .Nm
1.83 pascal 242: to exit early.
243: The string
1.84 jmc 244: .Qq {}
1.83 pascal 245: must appear, and must appear last.
246: Each set is limited to no more than 5,000 pathnames,
247: and is also limited such that the invocation of
1.63 otto 248: .Ar utility
1.83 pascal 249: does not exceed
250: .Dv ARG_MAX .
1.84 jmc 251: .Pp
1.89 jmc 252: .It Ic -execdir Ar utility Oo Ar argument ... Oc \&;
1.85 sthen 253: Identical to the first form of the
1.10 millert 254: .Ic -exec
255: primary with the exception that
1.16 aaron 256: .Ar utility
1.10 millert 257: will be executed from the directory that holds
1.25 aaron 258: the current file.
259: The filename substituted for the string
1.22 aaron 260: .Qq {}
261: is not qualified.
1.84 jmc 262: .Pp
1.28 millert 263: .It Xo
264: .Ic -flags
1.65 jmc 265: .Oo - Oc Ns Ar flags
1.28 millert 266: .Xc
267: The
268: .Ar flags
269: are comma-separated symbolic file flags (see
270: .Xr chflags 1
271: for a list of valid flag names).
272: If the flags are preceded by a dash
1.54 jmc 273: .Pq Sq - ,
1.49 otto 274: this primary evaluates to true if at least all specified
275: .Ar flags
276: are set in the file's flags.
1.28 millert 277: If the flags are not preceded by a dash, this primary evaluates to true if the
278: flags specified exactly match those of the file.
1.84 jmc 279: .Pp
1.2 deraadt 280: .It Ic -follow
1.61 jmc 281: This primary always evaluates to true.
1.56 jmc 282: The same as specifying the
1.86 halex 283: .Fl L
1.56 jmc 284: option.
1.84 jmc 285: .Pp
1.22 aaron 286: .It Ic -fstype Ar type
1.1 deraadt 287: True if the file is contained in a file system of type
288: .Ar type .
1.22 aaron 289: Two special file system types are recognized:
290: .Dq local
291: and
292: .Dq rdonly .
1.1 deraadt 293: These do not describe actual file system types;
294: the former matches any file system physically mounted on the system where
1.22 aaron 295: .Nm
296: is being executed whereas the latter matches any file system which is
1.1 deraadt 297: mounted read-only.
1.84 jmc 298: .Pp
1.22 aaron 299: .It Ic -group Ar gname
1.1 deraadt 300: True if the file belongs to the group
1.25 aaron 301: .Ar gname .
1.1 deraadt 302: If
303: .Ar gname
304: is numeric and there is no such group name, then
305: .Ar gname
1.16 aaron 306: is treated as a group ID.
1.84 jmc 307: .Pp
1.27 deraadt 308: .It Ic -iname Ar pattern
1.77 schwarze 309: Identical to the
310: .Ic -name
311: primary except that the matching is done in a case insensitive manner.
1.84 jmc 312: .Pp
1.22 aaron 313: .It Ic -inum Ar n
1.1 deraadt 314: True if the file has inode number
1.25 aaron 315: .Ar n .
1.84 jmc 316: .Pp
1.22 aaron 317: .It Ic -links Ar n
1.1 deraadt 318: True if the file has
319: .Ar n
320: links.
1.84 jmc 321: .Pp
1.1 deraadt 322: .It Ic -ls
323: This primary always evaluates to true.
324: The following information for the current file is written to standard output:
1.22 aaron 325: its inode number, size in 512-byte blocks, file permissions, number of hard
1.1 deraadt 326: links, owner, group, size in bytes, last modification time, and pathname.
327: If the file is a block or character special file, the major and minor numbers
328: will be displayed instead of the size in bytes.
1.22 aaron 329: If the file is a symbolic link, the pathname of the linked-to file will be
330: displayed preceded by
1.89 jmc 331: .Dq -> .
1.22 aaron 332: The format is identical to that produced by
1.71 jmc 333: .Dq ls -dils .
1.84 jmc 334: .Pp
1.6 tholo 335: .It Ic -maxdepth Ar n
1.7 tholo 336: True if the current search depth is less than or equal to what is specified in
337: .Ar n .
1.84 jmc 338: .Pp
1.7 tholo 339: .It Ic -mindepth Ar n
340: True if the current search depth is at least what is specified in
1.6 tholo 341: .Ar n .
1.84 jmc 342: .Pp
1.22 aaron 343: .It Ic -mmin Ar n
1.15 deraadt 344: True if the difference between the file last modification time and the time
1.22 aaron 345: .Nm
1.20 aaron 346: was started, rounded up to the next full minute, is
1.15 deraadt 347: .Ar n
1.20 aaron 348: minutes.
1.84 jmc 349: .Pp
1.22 aaron 350: .It Ic -mtime Ar n
1.1 deraadt 351: True if the difference between the file last modification time and the time
1.22 aaron 352: .Nm
353: was started, rounded up to the next full 24-hour period, is
1.1 deraadt 354: .Ar n
1.22 aaron 355: 24-hour periods.
1.84 jmc 356: .Pp
1.22 aaron 357: .It Ic -name Ar pattern
1.1 deraadt 358: True if the last component of the pathname being examined matches
1.77 schwarze 359: .Ar pattern ,
360: which may use any of the special characters documented in
361: .Xr glob 7 .
1.84 jmc 362: .Pp
1.22 aaron 363: .It Ic -newer Ar file
1.1 deraadt 364: True if the current file has a more recent last modification time than
1.25 aaron 365: .Ar file .
1.84 jmc 366: .Pp
1.44 jmc 367: .It Ic -nogroup
368: True if the file belongs to an unknown group.
1.84 jmc 369: .Pp
1.1 deraadt 370: .It Ic -nouser
371: True if the file belongs to an unknown user.
1.84 jmc 372: .Pp
1.89 jmc 373: .It Ic -ok Ar utility Oo Ar argument ... Oc \&;
1.22 aaron 374: Identical to the
375: .Ic -exec
376: primary with the exception that
377: .Nm
378: requests user affirmation for the execution of
379: .Ar utility
380: by printing
381: a message to the terminal and reading a response.
382: If the response is other than
383: .Sq y
384: the command is not executed and the
385: value of the
1.54 jmc 386: .Ic ok
1.22 aaron 387: expression is false.
1.84 jmc 388: .Pp
1.22 aaron 389: .It Ic -path Ar pattern
1.1 deraadt 390: True if the pathname being examined matches
1.77 schwarze 391: .Ar pattern ,
392: which may use any of the special characters documented in
393: .Xr glob 7 .
1.22 aaron 394: Slashes
395: .Pq Ql /
396: are treated as normal characters and do not have to be
1.1 deraadt 397: matched explicitly.
1.84 jmc 398: .Pp
1.21 aaron 399: .It Xo
400: .Ic -perm
1.65 jmc 401: .Oo - Oc Ns Ar mode
1.21 aaron 402: .Xc
1.1 deraadt 403: The
404: .Ar mode
405: may be either symbolic (see
1.25 aaron 406: .Xr chmod 1 )
1.1 deraadt 407: or an octal number.
408: If the mode is symbolic, a starting value of zero is assumed and the
1.16 aaron 409: mode sets or clears permissions without regard to the process's file mode
1.1 deraadt 410: creation mask.
411: If the mode is octal, only bits 07777
1.90 bentley 412: .Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
1.1 deraadt 413: of the file's mode bits participate
414: in the comparison.
1.22 aaron 415: If the mode is preceded by a dash
1.54 jmc 416: .Pq Sq - ,
1.22 aaron 417: this primary evaluates to true
1.1 deraadt 418: if at least all of the bits in the mode are set in the file's mode bits.
1.22 aaron 419: If the mode is not preceded by a dash, this primary evaluates to
1.16 aaron 420: true if the bits in the mode exactly match the file's mode bits.
1.22 aaron 421: Note, the first character of a symbolic mode may not be a dash.
1.84 jmc 422: .Pp
1.1 deraadt 423: .It Ic -print
424: This primary always evaluates to true.
425: It prints the pathname of the current file to standard output, followed
1.22 aaron 426: by a newline
427: .Pq Ql \en
428: character.
1.84 jmc 429: .Pp
1.1 deraadt 430: .It Ic -print0
431: This primary always evaluates to true.
432: It prints the pathname of the current file to standard output, followed
1.79 schwarze 433: by a null character, suitable for use with the
434: .Fl 0
435: option to
436: .Xr xargs 1 .
1.84 jmc 437: .Pp
1.1 deraadt 438: .It Ic -prune
439: This primary always evaluates to true.
440: It causes
1.22 aaron 441: .Nm
1.1 deraadt 442: to not descend into the current file.
443: Note, the
444: .Ic -prune
445: primary has no effect if the
446: .Fl d
447: option was specified.
1.84 jmc 448: .Pp
1.22 aaron 449: .It Ic -size Ar n Ns Op Cm c
450: True if the file's size, rounded up, in 512-byte blocks is
1.25 aaron 451: .Ar n .
1.1 deraadt 452: If
453: .Ar n
1.22 aaron 454: is followed by a
455: .Sq c ,
456: then the primary is true if the
1.1 deraadt 457: file's size is
458: .Ar n
459: bytes.
1.84 jmc 460: .Pp
1.22 aaron 461: .It Ic -type Ar t
1.1 deraadt 462: True if the file is of the specified type.
463: Possible file types are as follows:
464: .Pp
465: .Bl -tag -width flag -offset indent -compact
466: .It Cm b
467: block special
468: .It Cm c
469: character special
470: .It Cm d
471: directory
472: .It Cm f
473: regular file
474: .It Cm l
475: symbolic link
476: .It Cm p
477: FIFO
478: .It Cm s
479: socket
480: .El
481: .Pp
1.22 aaron 482: .It Ic -user Ar uname
1.1 deraadt 483: True if the file belongs to the user
1.25 aaron 484: .Ar uname .
1.1 deraadt 485: If
486: .Ar uname
487: is numeric and there is no such user name, then
488: .Ar uname
1.16 aaron 489: is treated as a user ID.
1.84 jmc 490: .Pp
1.56 jmc 491: .It Ic -xdev
1.61 jmc 492: This primary always evaluates to true.
1.56 jmc 493: The same as specifying the
494: .Fl x
495: option.
1.1 deraadt 496: .El
497: .Pp
498: All primaries which take a numeric argument allow the number to be
1.22 aaron 499: preceded by a plus sign
500: .Pq Ql +
501: or a minus sign
1.54 jmc 502: .Pq Ql - .
1.22 aaron 503: A preceding plus sign means
504: .Dq more than n ,
505: a preceding minus sign means
506: .Dq less than n ,
507: and neither means
508: .Dq exactly n .
1.74 jmc 509: Exceptions are the primaries
510: .Ic mindepth
511: and
512: .Ic maxdepth .
1.1 deraadt 513: .Sh OPERATORS
514: The primaries may be combined using the following operators.
515: The operators are listed in order of decreasing precedence.
1.47 jmc 516: .Pp
517: .Bl -tag -width "(expression)" -compact
1.51 jmc 518: .It Cm \&( Ar expression Cm \&)
1.1 deraadt 519: This evaluates to true if the parenthesized expression evaluates to
520: true.
521: .Pp
1.51 jmc 522: .It Cm \&! Ar expression
1.1 deraadt 523: This is the unary
524: .Tn NOT
525: operator.
526: It evaluates to true if the expression is false.
527: .Pp
1.89 jmc 528: .It Ar expression Cm -a Ar expression
1.22 aaron 529: .It Ar expression Cm -and Ar expression
530: .It Ar expression expression
1.89 jmc 531: The logical AND operator.
1.1 deraadt 532: As it is implied by the juxtaposition of two expressions it does not
533: have to be specified.
534: The expression evaluates to true if both expressions are true.
535: The second expression is not evaluated if the first expression is false.
536: .Pp
1.89 jmc 537: .It Ar expression Cm -o Ar expression
1.22 aaron 538: .It Ar expression Cm -or Ar expression
1.89 jmc 539: The logical OR operator.
1.1 deraadt 540: The expression evaluates to true if either the first or the second expression
541: is true.
542: The second expression is not evaluated if the first expression is true.
543: .El
544: .Pp
1.53 otto 545: Operators, primaries, and arguments to primaries must be separate
546: arguments to
547: .Nm find ,
548: i.e. they should be separated by whitespace.
1.81 jmc 549: .Sh EXIT STATUS
550: The
551: .Nm
552: utility exits with a value of 0 on successful traversal of all path operands
1.89 jmc 553: or with a value >0 if an error occurred.
1.1 deraadt 554: .Sh EXAMPLES
1.62 jmc 555: Print out a list of all the files whose names end in
1.43 jaredy 556: .Dq \&.c :
557: .Pp
1.62 jmc 558: .Dl "$ find / -name '*.c'"
1.43 jaredy 559: .Pp
1.22 aaron 560: Print out a list of all the files which are not both newer than
561: .Dq ttt
562: and owned by
1.43 jaredy 563: .Dq wnj :
564: .Pp
1.62 jmc 565: .Dl "$ find / \e! \e( -newer ttt -user wnj \e)"
1.43 jaredy 566: .Pp
567: Print out a list of all core files on local file systems:
568: .Pp
1.88 jmc 569: .Dl "$ find / \e! -fstype local -prune -o -name '*.core'"
1.46 jmc 570: .Pp
571: Find all files in
572: .Pa /usr/src
573: ending in a dot and single digit, but skip directory
574: .Pa /usr/src/gnu :
575: .Pp
1.88 jmc 576: .Dl "$ find /usr/src -path /usr/src/gnu -prune -o -name \e*.[0-9]"
1.62 jmc 577: .Pp
1.79 schwarze 578: Find and remove all *.jpg and *.gif files under the current working
579: directory:
1.62 jmc 580: .Pp
1.88 jmc 581: .Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -exec rm {} \e;"
1.63 otto 582: or
1.88 jmc 583: .Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -print0 | xargs -0r rm"
1.1 deraadt 584: .Sh SEE ALSO
1.29 millert 585: .Xr chflags 1 ,
1.1 deraadt 586: .Xr chmod 1 ,
587: .Xr locate 1 ,
1.77 schwarze 588: .Xr ls 1 ,
1.23 aaron 589: .Xr whereis 1 ,
590: .Xr which 1 ,
1.41 millert 591: .Xr xargs 1 ,
1.1 deraadt 592: .Xr stat 2 ,
593: .Xr fts 3 ,
1.77 schwarze 594: .Xr glob 7 ,
1.1 deraadt 595: .Xr symlink 7
596: .Sh STANDARDS
597: The
1.22 aaron 598: .Nm
1.68 jmc 599: utility is compliant with the
1.72 jmc 600: .St -p1003.1-2008
1.68 jmc 601: specification.
1.1 deraadt 602: .Pp
1.55 jmc 603: The options
1.88 jmc 604: .Op Fl dfhXx ,
605: primaries
1.18 deraadt 606: .Ic -amin ,
1.55 jmc 607: .Ic -anewer ,
1.18 deraadt 608: .Ic -cmin ,
1.55 jmc 609: .Ic -cnewer ,
1.92 tedu 610: .Ic -delete ,
1.9 tholo 611: .Ic -empty ,
1.55 jmc 612: .Ic -execdir ,
613: .Ic -flags ,
1.1 deraadt 614: .Ic -follow ,
615: .Ic -fstype ,
1.27 deraadt 616: .Ic -iname ,
1.2 deraadt 617: .Ic -inum ,
1.9 tholo 618: .Ic -ls ,
619: .Ic -maxdepth ,
1.13 deraadt 620: .Ic -mindepth ,
1.55 jmc 621: .Ic -mmin ,
1.1 deraadt 622: and
1.88 jmc 623: .Ic -print0 ,
624: and operators
625: .Fl or
626: and
627: .Fl and ,
1.68 jmc 628: are extensions to that specification.
1.1 deraadt 629: .Pp
630: Historically, the
631: .Fl d ,
1.86 halex 632: .Fl L ,
1.1 deraadt 633: and
634: .Fl x
1.14 deraadt 635: options were implemented using the primaries
636: .Ic -depth ,
637: .Ic -follow ,
638: and
639: .Ic -xdev .
1.1 deraadt 640: These primaries always evaluated to true.
641: As they were really global variables that took effect before the traversal
642: began, some legal expressions could have unexpected results.
1.22 aaron 643: An example is the expression
1.54 jmc 644: .Dq -print -o -depth .
1.22 aaron 645: As
1.54 jmc 646: .Cm -print
1.22 aaron 647: always evaluates to true, the standard order of evaluation
648: implies that
1.54 jmc 649: .Cm -depth
1.22 aaron 650: would never be evaluated.
1.1 deraadt 651: This is not the case.
652: .Pp
653: Historic implementations of the
654: .Ic -exec
655: and
656: .Ic -ok
1.22 aaron 657: primaries did not replace the string
658: .Qq {}
659: in the utility name or the
1.1 deraadt 660: utility arguments if it had preceding or following non-whitespace characters.
661: This version replaces it no matter where in the utility name or arguments
662: it appears.
1.30 aaron 663: .Sh HISTORY
664: A
665: .Nm
666: command appeared in
667: .At v1 .
1.50 jmc 668: .Sh CAVEATS
1.1 deraadt 669: The special characters used by
1.22 aaron 670: .Nm
1.1 deraadt 671: are also special characters to many shell programs.
1.22 aaron 672: In particular, the characters
673: .Ql * ,
1.78 schwarze 674: .Ql \&[ ,
1.22 aaron 675: .Ql \&] ,
1.40 jmc 676: .Ql \&? ,
1.78 schwarze 677: .Ql \&( ,
1.22 aaron 678: .Ql \&) ,
1.40 jmc 679: .Ql \&! ,
1.22 aaron 680: .Ql \e ,
681: and
682: .Ql \&;
683: may have to be escaped from the shell.
1.79 schwarze 684: .Pp
1.82 schwarze 685: As file names may contain whitespace and shell metacharacters,
686: passing the output of
1.79 schwarze 687: .Nm
688: to other programs requires some care:
689: .Pp
690: .Dl "$ find . -name \e*.jpg | xargs rm"
691: or
692: .Dl "$ rm `find . -name \e*.jpg`"
693: .Pp
694: would, given files
695: .Dq important\ .jpg
696: and
697: .Dq important ,
698: remove
699: .Dq important .
700: Use the
701: .Ic -print0
702: or
703: .Ic -exec
704: primaries instead.
1.1 deraadt 705: .Pp
706: As there is no delimiter separating options and file names or file
707: names and the
708: .Ar expression ,
1.22 aaron 709: it is difficult to specify files named
710: .Dq -xdev
711: or
1.65 jmc 712: .Sq \&! .
1.1 deraadt 713: These problems are handled by the
714: .Fl f
715: option and the
716: .Xr getopt 3
1.65 jmc 717: .Sq --
1.22 aaron 718: construct.