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