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