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