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