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