]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/find/find.1
This commit was generated by cvs2svn to compensate for changes in r160157,
[FreeBSD/FreeBSD.git] / usr.bin / find / find.1
1 .\" Copyright (c) 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the Institute of Electrical and Electronics Engineers, Inc.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)find.1      8.7 (Berkeley) 5/9/95
36 .\" $FreeBSD$
37 .\"
38 .Dd May 27, 2006
39 .Dt FIND 1
40 .Os
41 .Sh NAME
42 .Nm find
43 .Nd walk a file hierarchy
44 .Sh SYNOPSIS
45 .Nm
46 .Op Fl H | Fl L | Fl P
47 .Op Fl EXdsx
48 .Op Fl f Ar pathname
49 .Op Ar pathname ...
50 .Ar expression
51 .Sh DESCRIPTION
52 The
53 .Nm
54 utility recursively descends the directory tree for each
55 .Ar pathname
56 listed, evaluating an
57 .Ar expression
58 (composed of the
59 .Dq primaries
60 and
61 .Dq operands
62 listed below) in terms
63 of each file in the tree.
64 .Pp
65 The options are as follows:
66 .Bl -tag -width indent
67 .It Fl E
68 Interpret regular expressions followed by
69 .Ic -regex
70 and
71 .Ic -iregex
72 options as extended (modern) regular expressions rather than basic
73 regular expressions (BRE's).
74 The
75 .Xr re_format 7
76 manual page fully describes both formats.
77 .It Fl H
78 Cause the file information and file type (see
79 .Xr stat 2 )
80 returned for each symbolic link specified on the command line to be
81 those of the file referenced by the link, not the link itself.
82 If the referenced file does not exist, the file information and type will
83 be for the link itself.
84 File information of all symbolic links not on
85 the command line is that of the link itself.
86 .It Fl L
87 Cause the file information and file type (see
88 .Xr stat 2 )
89 returned for each symbolic link to be those of the file referenced by the
90 link, not the link itself.
91 If the referenced file does not exist, the file information and type will
92 be for the link itself.
93 .Pp
94 This option is equivalent to the deprecated
95 .Ic -follow
96 primary.
97 .It Fl P
98 Cause the file information and file type (see
99 .Xr stat 2 )
100 returned for each symbolic link to be those of the link itself.
101 This is the default.
102 .It Fl X
103 Permit
104 .Nm
105 to be safely used in conjunction with
106 .Xr xargs 1 .
107 If a file name contains any of the delimiting characters used by
108 .Xr xargs 1 ,
109 a diagnostic message is displayed on standard error, and the file
110 is skipped.
111 The delimiting characters include single
112 .Pq Dq Li " ' "
113 and double
114 .Pq Dq Li " \*q "
115 quotes, backslash
116 .Pq Dq Li \e ,
117 space, tab and newline characters.
118 .Pp
119 However, you may wish to consider the
120 .Fl print0
121 primary in conjunction with
122 .Dq Nm xargs Fl 0
123 as an effective alternative.
124 .It Fl d
125 Cause
126 .Nm
127 to perform a depth-first traversal, i.e., directories
128 are visited in post-order and all entries in a directory will be acted
129 on before the directory itself.
130 By default,
131 .Nm
132 visits directories in pre-order, i.e., before their contents.
133 Note, the default is
134 .Em not
135 a breadth-first traversal.
136 .Pp
137 This option is equivalent to the
138 .Ic -depth
139 primary of
140 .St -p1003.1-2001 .
141 .Fl d
142 can be useful when
143 .Nm
144 is used with
145 .Xr cpio 1
146 to process files that are contained in directories with unusual permissions.
147 It ensures that you have write permission while you are placing files in a
148 directory, then sets the directory's permissions as the last thing.
149 .It Fl f
150 Specify a file hierarchy for
151 .Nm
152 to traverse.
153 File hierarchies may also be specified as the operands immediately
154 following the options.
155 .It Fl s
156 Cause
157 .Nm
158 to traverse the file hierarchies in lexicographical order,
159 i.e., alphabetical order within each directory.
160 Note:
161 .Ql find -s
162 and
163 .Ql "find | sort"
164 may give different results.
165 .It Fl x
166 Prevent
167 .Nm
168 from descending into directories that have a device number different
169 than that of the file from which the descent began.
170 .Pp
171 This option is equivalent to the deprecated
172 .Ic -xdev
173 primary.
174 .El
175 .Sh PRIMARIES
176 .Bl -tag -width indent
177 .It Ic -Bmin Ar n
178 True if the difference between the time of a file's inode creation
179 and the time
180 .Nm
181 was started, rounded up to the next full minute, is
182 .Ar n
183 minutes.
184 .It Ic -Bnewer Ar file
185 Same as
186 .Ic -newerBm .
187 .It Ic -Btime Ar n Ns Op Cm smhdw
188 If no units are specified, this primary evaluates to
189 true if the difference between the time of a file's inode creation
190 and the time
191 .Nm
192 was started, rounded up to the next full 24-hour period, is
193 .Ar n
194 24-hour periods.
195 .Pp
196 If units are specified, this primary evaluates to
197 true if the difference between the time of last change of file status
198 information and the time
199 .Nm
200 was started is exactly
201 .Ar n
202 units.
203 Please refer to the
204 .Ic -atime
205 primary description for information on supported time units.
206 .It Ic -acl
207 May be used in conjunction with other options to locate
208 files with extended ACLs.
209 See
210 .Xr acl 3
211 for more information.
212 .It Ic -amin Ar n
213 True if the difference between the file last access time and the time
214 .Nm
215 was started, rounded up to the next full minute, is
216 .Ar n
217 minutes.
218 .It Ic -anewer Ar file
219 Same as
220 .Ic -neweram .
221 .It Ic -atime Ar n Ns Op Cm smhdw
222 If no units are specified, this primary evaluates to
223 true if the difference between the file last access time and the time
224 .Nm
225 was started, rounded up to the next full 24-hour period, is
226 .Ar n
227 24-hour periods.
228 .Pp
229 If units are specified, this primary evaluates to
230 true if the difference between the file last access time and the time
231 .Nm
232 was started is exactly
233 .Ar n
234 units.
235 Possible time units are as follows:
236 .Pp
237 .Bl -tag -width indent -compact
238 .It Cm s
239 second
240 .It Cm m
241 minute (60 seconds)
242 .It Cm h
243 hour (60 minutes)
244 .It Cm d
245 day (24 hours)
246 .It Cm w
247 week (7 days)
248 .El
249 .Pp
250 Any number of units may be combined in one
251 .Ic -atime
252 argument, for example,
253 .Dq Li "-atime -1h30m" .
254 Units are probably only useful when used in conjunction with the
255 .Cm +
256 or
257 .Cm -
258 modifier.
259 .It Ic -cmin Ar n
260 True if the difference between the time of last change of file status
261 information and the time
262 .Nm
263 was started, rounded up to the next full minute, is
264 .Ar n
265 minutes.
266 .It Ic -cnewer Ar file
267 Same as
268 .Ic -newercm .
269 .It Ic -ctime Ar n Ns Op Cm smhdw
270 If no units are specified, this primary evaluates to
271 true if the difference between the time of last change of file status
272 information and the time
273 .Nm
274 was started, rounded up to the next full 24-hour period, is
275 .Ar n
276 24-hour periods.
277 .Pp
278 If units are specified, this primary evaluates to
279 true if the difference between the time of last change of file status
280 information and the time
281 .Nm
282 was started is exactly
283 .Ar n
284 units.
285 Please refer to the
286 .Ic -atime
287 primary description for information on supported time units.
288 .It Ic -delete
289 Delete found files and/or directories.
290 Always returns true.
291 This executes
292 from the current working directory as
293 .Nm
294 recurses down the tree.
295 It will not attempt to delete a filename with a
296 .Dq Pa /
297 character in its pathname relative to
298 .Dq Pa \&.
299 for security reasons.
300 Depth-first traversal processing is implied by this option.
301 .It Ic -depth
302 Always true;
303 same as the
304 .Fl d
305 option.
306 .It Ic -depth Ar n
307 True if the depth of the file relative to the starting point of the traversal
308 is
309 .Ar n .
310 .It Ic -empty
311 True if the current file or directory is empty.
312 .It Ic -exec Ar utility Oo Ar argument ... Oc Li \&;
313 True if the program named
314 .Ar utility
315 returns a zero value as its exit status.
316 Optional
317 .Ar arguments
318 may be passed to the utility.
319 The expression must be terminated by a semicolon
320 .Pq Dq Li \&; .
321 If you invoke
322 .Nm
323 from a shell you may need to quote the semicolon if the shell would
324 otherwise treat it as a control operator.
325 If the string
326 .Dq Li {}
327 appears anywhere in the utility name or the
328 arguments it is replaced by the pathname of the current file.
329 .Ar Utility
330 will be executed from the directory from which
331 .Nm
332 was executed.
333 .Ar Utility
334 and
335 .Ar arguments
336 are not subject to the further expansion of shell patterns
337 and constructs.
338 .It Ic -exec Ar utility Oo Ar argument ... Oc Li {} +
339 Same as
340 .Ic -exec ,
341 except that
342 .Dq Li {}
343 is replaced with as many pathnames as possible for each invocation of
344 .Ar utility .
345 This behaviour is similar to that of
346 .Xr xargs 1 .
347 .It Ic -execdir Ar utility Oo Ar argument ... Oc Li \&;
348 The
349 .Ic -execdir
350 primary is identical to the
351 .Ic -exec
352 primary with the exception that
353 .Ar utility
354 will be executed from the directory that holds
355 the current file.
356 The filename substituted for
357 the string
358 .Dq Li {}
359 is not qualified.
360 .It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags
361 The flags are specified using symbolic names (see
362 .Xr chflags 1 ) .
363 Those with the
364 .Qq Li no
365 prefix (except
366 .Qq Li nodump )
367 are said to be
368 .Ar notflags .
369 Flags in
370 .Ar flags
371 are checked to be set, and flags in
372 .Ar notflags
373 are checked to be not set.
374 Note that this is different from
375 .Ic -perm ,
376 which only allows the user to specify mode bits that are set.
377 .Pp
378 If flags are preceded by a dash
379 .Pq Dq Li - ,
380 this primary evaluates to true
381 if at least all of the bits in
382 .Ar flags
383 and none of the bits in
384 .Ar notflags
385 are set in the file's flags bits.
386 If flags are preceded by a plus
387 .Pq Dq Li + ,
388 this primary evaluates to true
389 if any of the bits in
390 .Ar flags
391 is set in the file's flags bits,
392 or any of the bits in
393 .Ar notflags
394 is not set in the file's flags bits.
395 Otherwise,
396 this primary evaluates to true
397 if the bits in
398 .Ar flags
399 exactly match the file's flags bits,
400 and none of the
401 .Ar flags
402 bits match those of
403 .Ar notflags .
404 .It Ic -fstype Ar type
405 True if the file is contained in a file system of type
406 .Ar type .
407 The
408 .Xr sysctl 8
409 command can be used to find out the types of file systems
410 that are available on the system:
411 .Pp
412 .Dl "sysctl vfs"
413 .Pp
414 In addition, there are two pseudo-types,
415 .Dq Li local
416 and
417 .Dq Li rdonly .
418 The former matches any file system physically mounted on the system where
419 the
420 .Nm
421 is being executed and the latter matches any file system which is
422 mounted read-only.
423 .It Ic -group Ar gname
424 True if the file belongs to the group
425 .Ar gname .
426 If
427 .Ar gname
428 is numeric and there is no such group name, then
429 .Ar gname
430 is treated as a group ID.
431 .It Ic -iname Ar pattern
432 Like
433 .Ic -name ,
434 but the match is case insensitive.
435 .It Ic -inum Ar n
436 True if the file has inode number
437 .Ar n .
438 .It Ic -ipath Ar pattern
439 Like
440 .Ic -path ,
441 but the match is case insensitive.
442 .It Ic -iregex Ar pattern
443 Like
444 .Ic -regex ,
445 but the match is case insensitive.
446 .It Ic -links Ar n
447 True if the file has
448 .Ar n
449 links.
450 .It Ic -ls
451 This primary always evaluates to true.
452 The following information for the current file is written to standard output:
453 its inode number, size in 512-byte blocks, file permissions, number of hard
454 links, owner, group, size in bytes, last modification time, and pathname.
455 If the file is a block or character special file, the major and minor numbers
456 will be displayed instead of the size in bytes.
457 If the file is a symbolic link, the pathname of the linked-to file will be
458 displayed preceded by
459 .Dq Li -> .
460 The format is identical to that produced by
461 .Bk -words
462 .Nm ls Fl dgils .
463 .Ek
464 .It Ic -maxdepth Ar n
465 Always true; descend at most
466 .Ar n
467 directory levels below the command line arguments.
468 If any
469 .Ic -maxdepth
470 primary is specified, it applies to the entire expression even if it would
471 not normally be evaluated.
472 .Ic -maxdepth Li 0
473 limits the whole search to the command line arguments.
474 .It Ic -mindepth Ar n
475 Always true; do not apply any tests or actions at levels less than
476 .Ar n .
477 If any
478 .Ic -mindepth
479 primary is specified, it applies to the entire expression even if it would
480 not normally be evaluated.
481 .Ic -mindepth Li 1
482 processes all but the command line arguments.
483 .It Ic -mmin Ar n
484 True if the difference between the file last modification time and the time
485 .Nm
486 was started, rounded up to the next full minute, is
487 .Ar n
488 minutes.
489 .It Ic -mnewer Ar file
490 Same as
491 .Ic -newer .
492 .It Ic -mtime Ar n Ns Op Cm smhdw
493 If no units are specified, this primary evaluates to
494 true if the difference between the file last modification time and the time
495 .Nm
496 was started, rounded up to the next full 24-hour period, is
497 .Ar n
498 24-hour periods.
499 .Pp
500 If units are specified, this primary evaluates to
501 true if the difference between the file last modification time and the time
502 .Nm
503 was started is exactly
504 .Ar n
505 units.
506 Please refer to the
507 .Ic -atime
508 primary description for information on supported time units.
509 .It Ic -name Ar pattern
510 True if the last component of the pathname being examined matches
511 .Ar pattern .
512 Special shell pattern matching characters
513 .Dq ( Li \&[ ,
514 .Dq Li \&] ,
515 .Dq Li * ,
516 and
517 .Dq Li \&? )
518 may be used as part of
519 .Ar pattern .
520 These characters may be matched explicitly by escaping them with a
521 backslash
522 .Pq Dq Li \e .
523 .It Ic -newer Ar file
524 True if the current file has a more recent last modification time than
525 .Ar file .
526 .It Ic -newer Ns Ar X Ns Ar Y Ar file
527 True if the current file has a more recent last access time
528 .Ar ( X Ns = Ns Cm a ) ,
529 inode creation time
530 .Ar ( X Ns = Ns Cm B ) ,
531 change time
532 .Ar ( X Ns = Ns Cm c ) ,
533 or modification time
534 .Ar ( X Ns = Ns Cm m )
535 than the last access time
536 .Ar ( Y Ns = Ns Cm a ) ,
537 inode creation time
538 .Ar ( Y Ns = Ns Cm B ) ,
539 change time
540 .Ar ( Y Ns = Ns Cm c ) ,
541 or modification time
542 .Ar ( Y Ns = Ns Cm m )
543 of
544 .Ar file .
545 In addition, if
546 .Ar Y Ns = Ns Cm t ,
547 then
548 .Ar file
549 is instead interpreted as a direct date specification of the form
550 understood by
551 .Xr cvs 1 .
552 Note that
553 .Ic -newermm
554 is equivalent to
555 .Ic -newer .
556 .It Ic -nogroup
557 True if the file belongs to an unknown group.
558 .It Ic -nouser
559 True if the file belongs to an unknown user.
560 .It Ic -ok Ar utility Oo Ar argument ... Oc Li \&;
561 The
562 .Ic -ok
563 primary is identical to the
564 .Ic -exec
565 primary with the exception that
566 .Nm
567 requests user affirmation for the execution of the
568 .Ar utility
569 by printing
570 a message to the terminal and reading a response.
571 If the response is not affirmative
572 .Ql ( y
573 in the
574 .Dq Li POSIX
575 locale),
576 the command is not executed and the
577 value of the
578 .Ic -ok
579 expression is false.
580 .It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&;
581 The
582 .Ic -okdir
583 primary is identical to the
584 .Ic -execdir
585 primary with the same exception as described for the
586 .Ic -ok
587 primary.
588 .It Ic -path Ar pattern
589 True if the pathname being examined matches
590 .Ar pattern .
591 Special shell pattern matching characters
592 .Dq ( Li \&[ ,
593 .Dq Li \&] ,
594 .Dq Li * ,
595 and
596 .Dq Li \&? )
597 may be used as part of
598 .Ar pattern .
599 These characters may be matched explicitly by escaping them with a
600 backslash
601 .Pq Dq Li \e .
602 Slashes
603 .Pq Dq Li /
604 are treated as normal characters and do not have to be
605 matched explicitly.
606 .It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode
607 The
608 .Ar mode
609 may be either symbolic (see
610 .Xr chmod 1 )
611 or an octal number.
612 If the
613 .Ar mode
614 is symbolic, a starting value of zero is assumed and the
615 .Ar mode
616 sets or clears permissions without regard to the process' file mode
617 creation mask.
618 If the
619 .Ar mode
620 is octal, only bits 07777
621 .Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO
622 of the file's mode bits participate
623 in the comparison.
624 If the
625 .Ar mode
626 is preceded by a dash
627 .Pq Dq Li - ,
628 this primary evaluates to true
629 if at least all of the bits in the
630 .Ar mode
631 are set in the file's mode bits.
632 If the
633 .Ar mode
634 is preceded by a plus
635 .Pq Dq Li + ,
636 this primary evaluates to true
637 if any of the bits in the
638 .Ar mode
639 are set in the file's mode bits.
640 Otherwise, this primary evaluates to true if
641 the bits in the
642 .Ar mode
643 exactly match the file's mode bits.
644 Note, the first character of a symbolic mode may not be a dash
645 .Pq Dq Li - .
646 .It Ic -print
647 This primary always evaluates to true.
648 It prints the pathname of the current file to standard output.
649 If none of
650 .Ic -exec , -ls , -print0 ,
651 or
652 .Ic -ok
653 is specified, the given expression shall be effectively replaced by
654 .Cm \&( Ar "given expression" Cm \&) Ic -print .
655 .It Ic -print0
656 This primary always evaluates to true.
657 It prints the pathname of the current file to standard output, followed by an
658 .Tn ASCII NUL
659 character (character code 0).
660 .It Ic -prune
661 This primary always evaluates to true.
662 It causes
663 .Nm
664 to not descend into the current file.
665 Note, the
666 .Ic -prune
667 primary has no effect if the
668 .Fl d
669 option was specified.
670 .It Ic -regex Ar pattern
671 True if the whole path of the file matches
672 .Ar pattern
673 using regular expression.
674 To match a file named
675 .Dq Pa ./foo/xyzzy ,
676 you can use the regular expression
677 .Dq Li ".*/[xyz]*"
678 or
679 .Dq Li ".*/foo/.*" ,
680 but not
681 .Dq Li xyzzy
682 or
683 .Dq Li /foo/ .
684 .It Ic -size Ar n Ns Op Cm ckMGTP
685 True if the file's size, rounded up, in 512-byte blocks is
686 .Ar n .
687 If
688 .Ar n
689 is followed by a
690 .Cm c ,
691 then the primary is true if the
692 file's size is
693 .Ar n
694 bytes (characters).
695 Similarly if
696 .Ar n
697 is followed by a scale indicator then the file's size is compared to
698 .Ar n
699 scaled as:
700 .Pp
701 .Bl -tag -width indent -compact
702 .It Cm k
703 kilobytes (1024 bytes)
704 .It Cm M
705 megabytes (1024 kilobytes)
706 .It Cm G
707 gigabytes (1024 megabytes)
708 .It Cm T
709 terabytes (1024 gigabytes)
710 .It Cm P
711 petabytes (1024 terabytes)
712 .El
713 .Pp
714 .It Ic -type Ar t
715 True if the file is of the specified type.
716 Possible file types are as follows:
717 .Pp
718 .Bl -tag -width indent -compact
719 .It Cm b
720 block special
721 .It Cm c
722 character special
723 .It Cm d
724 directory
725 .It Cm f
726 regular file
727 .It Cm l
728 symbolic link
729 .It Cm p
730 FIFO
731 .It Cm s
732 socket
733 .El
734 .It Ic -user Ar uname
735 True if the file belongs to the user
736 .Ar uname .
737 If
738 .Ar uname
739 is numeric and there is no such user name, then
740 .Ar uname
741 is treated as a user ID.
742 .El
743 .Pp
744 All primaries which take a numeric argument allow the number to be
745 preceded by a plus sign
746 .Pq Dq Li +
747 or a minus sign
748 .Pq Dq Li - .
749 A preceding plus sign means
750 .Dq more than n ,
751 a preceding minus sign means
752 .Dq less than n
753 and neither means
754 .Dq exactly n .
755 .Sh OPERATORS
756 The primaries may be combined using the following operators.
757 The operators are listed in order of decreasing precedence.
758 .Pp
759 .Bl -tag -width "( expression )" -compact
760 .It Cm \&( Ar expression Cm \&)
761 This evaluates to true if the parenthesized expression evaluates to
762 true.
763 .Pp
764 .It Cm \&! Ar expression
765 .It Cm -false Ar expression
766 .It Cm -not Ar expression
767 This is the unary
768 .Tn NOT
769 operator.
770 It evaluates to true if the expression is false.
771 .Pp
772 .It Ar expression Cm -and Ar expression
773 .It Ar expression expression
774 The
775 .Cm -and
776 operator is the logical
777 .Tn AND
778 operator.
779 As it is implied by the juxtaposition of two expressions it does not
780 have to be specified.
781 The expression evaluates to true if both expressions are true.
782 The second expression is not evaluated if the first expression is false.
783 .Pp
784 .It Ar expression Cm -or Ar expression
785 The
786 .Cm -or
787 operator is the logical
788 .Tn OR
789 operator.
790 The expression evaluates to true if either the first or the second expression
791 is true.
792 The second expression is not evaluated if the first expression is true.
793 .El
794 .Pp
795 All operands and primaries must be separate arguments to
796 .Nm .
797 Primaries which themselves take arguments expect each argument
798 to be a separate argument to
799 .Nm .
800 .Sh ENVIRONMENT
801 The
802 .Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES
803 and
804 .Ev LC_TIME
805 environment variables affect the execution of the
806 .Nm
807 utility as described in
808 .Xr environ 7 .
809 .Sh EXAMPLES
810 The following examples are shown as given to the shell:
811 .Bl -tag -width indent
812 .It Li "find / \e! -name \*q*.c\*q -print"
813 Print out a list of all the files whose names do not end in
814 .Pa .c .
815 .It Li "find / -newer ttt -user wnj -print"
816 Print out a list of all the files owned by user
817 .Dq wnj
818 that are newer
819 than the file
820 .Pa ttt .
821 .It Li "find / \e! \e( -newer ttt -user wnj \e) -print"
822 Print out a list of all the files which are not both newer than
823 .Pa ttt
824 and owned by
825 .Dq wnj .
826 .It Li "find / \e( -newer ttt -or -user wnj \e) -print"
827 Print out a list of all the files that are either owned by
828 .Dq wnj
829 or that are newer than
830 .Pa ttt .
831 .It Li "find / -newerct '1 minute ago' -print"
832 Print out a list of all the files whose inode change time is more
833 recent than the current time minus one minute.
834 .It Li "find / -type f -exec echo {} \e;"
835 Use the
836 .Xr echo 1
837 command to print out a list of all the files.
838 .It Li "find -L /usr/ports/packages -type l -delete"
839 Delete all broken symbolic links in
840 .Pa /usr/ports/packages .
841 .It Li "find /usr/src -name CVS -prune -o -depth +6 -print"
842 Find files and directories that are at least seven levels deep
843 in the working directory
844 .Pa /usr/src .
845 .It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print"
846 Is not equivalent to the previous example, since
847 .Ic -prune
848 is not evaluated below level seven.
849 .El
850 .Sh COMPATIBILITY
851 The
852 .Ic -follow
853 primary is deprecated; the
854 .Fl L
855 option should be used instead.
856 See the
857 .Sx STANDARDS
858 section below for details.
859 .Sh SEE ALSO
860 .Xr chflags 1 ,
861 .Xr chmod 1 ,
862 .Xr cvs 1 ,
863 .Xr locate 1 ,
864 .Xr whereis 1 ,
865 .Xr which 1 ,
866 .Xr xargs 1 ,
867 .Xr stat 2 ,
868 .Xr acl 3 ,
869 .Xr fts 3 ,
870 .Xr getgrent 3 ,
871 .Xr getpwent 3 ,
872 .Xr strmode 3 ,
873 .Xr re_format 7 ,
874 .Xr symlink 7
875 .Sh STANDARDS
876 The
877 .Nm
878 utility syntax is a superset of the syntax specified by the
879 .St -p1003.1-2001
880 standard.
881 .Pp
882 All the single character options except
883 .Ic -H
884 and
885 .Ic -L
886 as well as the
887 .Ic -iname , -inum , -iregex , -print0 , -delete , -ls , -regex ,
888 and all of the
889 .Ic -B
890 birthtime related primaries are extensions to
891 .St -p1003.1-2001 .
892 .Pp
893 Historically, the
894 .Fl d , L
895 and
896 .Fl x
897 options were implemented using the primaries
898 .Ic -depth , -follow ,
899 and
900 .Ic -xdev .
901 These primaries always evaluated to true.
902 As they were really global variables that took effect before the traversal
903 began, some legal expressions could have unexpected results.
904 An example is the expression
905 .Ic -print Cm -o Ic -depth .
906 As
907 .Ic -print
908 always evaluates to true, the standard order of evaluation
909 implies that
910 .Ic -depth
911 would never be evaluated.
912 This is not the case.
913 .Pp
914 The operator
915 .Cm -or
916 was implemented as
917 .Cm -o ,
918 and the operator
919 .Cm -and
920 was implemented as
921 .Cm -a .
922 .Pp
923 Historic implementations of the
924 .Ic -exec
925 and
926 .Ic -ok
927 primaries did not replace the string
928 .Dq Li {}
929 in the utility name or the
930 utility arguments if it had preceding or following non-whitespace characters.
931 This version replaces it no matter where in the utility name or arguments
932 it appears.
933 .Pp
934 The
935 .Fl E
936 option was inspired by the equivalent
937 .Xr grep 1
938 and
939 .Xr sed 1
940 options.
941 .Sh HISTORY
942 A
943 .Nm
944 command appeared in
945 .At v1 .
946 .Sh BUGS
947 The special characters used by
948 .Nm
949 are also special characters to many shell programs.
950 In particular, the characters
951 .Dq Li * ,
952 .Dq Li \&[ ,
953 .Dq Li \&] ,
954 .Dq Li \&? ,
955 .Dq Li \&( ,
956 .Dq Li \&) ,
957 .Dq Li \&! ,
958 .Dq Li \e
959 and
960 .Dq Li \&;
961 may have to be escaped from the shell.
962 .Pp
963 As there is no delimiter separating options and file names or file
964 names and the
965 .Ar expression ,
966 it is difficult to specify files named
967 .Pa -xdev
968 or
969 .Pa \&! .
970 These problems are handled by the
971 .Fl f
972 option and the
973 .Xr getopt 3
974 .Dq Fl Fl
975 construct.
976 .Pp
977 The
978 .Ic -delete
979 primary does not interact well with other options that cause the file system
980 tree traversal options to be changed.
981 .Pp
982 The
983 .Ic -mindepth
984 and
985 .Ic -maxdepth
986 primaries are actually global options (as documented above).
987 They should
988 probably be replaced by options which look like options.