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