Manual conflict resolution following CVS merge
[findutils.git] / find / find.1
blob230ed9fc0a7400ba586d31acf3d73ef7f9111e3e
1 .TH FIND 1 \" -*- nroff -*-
2 .SH NAME
3 find \- search for files in a directory hierarchy
4 .SH SYNOPSIS
5 .B find 
6 [\-H] [\-L] [\-P] [\-D debugopts] [\-Olevel] [path...] [expression]
7 .SH DESCRIPTION
8 This manual page
9 documents the GNU version of
10 .BR find .
11 GNU
12 .B find
13 searches the directory tree rooted at each given file name by
14 evaluating the given expression from left to right, according to the
15 rules of precedence (see section OPERATORS), until the outcome is
16 known (the left hand side is false for \fIand\fR operations, true for
17 \fIor\fR), at which point
18 .B find
19 moves on to the next file name.
20 .PP
21 If you are using 
22 .B find 
23 in an environment where security is important (for example if you are
24 using it to seach directories that are writable by other users), you
25 should read the "Security Considerations" chapter of the findutils
26 documentation, which is called \fBFinding Files\fP and comes with
27 findutils.   That document also includes a lot more detail 
28 and discussion than this manual page, so you may find it a more useful 
29 source of information.
30 .SH OPTIONS
31 The `\-H', `\-L' and `\-P' options control the treatment of symbolic
32 links.  Command-line arguments following these are taken to be names
33 of files or directories to be examined, up to the first argument that
34 begins with `\-', or the argument `(' or `!'.  That argument and any
35 following arguments are taken to be the expression describing what is
36 to be searched for.  If no paths are given, the current directory is
37 used.  If no expression is given, the expression `\-print' is used
38 (but you should probably consider using `\-print0' instead, anyway).
39 .PP
40 This manual page talks about `options' within the expression list.
41 These options control the behaviour of 
42 .B find
43 but are specified immediately after the last path name.  The five
44 `real' options `\-H', `\-L', `\-P', `\-D' and `\-O' must appear before
45 the first path name, if at all.  A double dash `\-\-' can also be used
46 to signal that any remaining arguments are not options (though
47 ensuring that all start points begin with either `./' or `/' is
48 generally safer if you use wildcards in the list of start points).
49 .IP \-P
50 Never follow symbolic links.  This is the default behaviour.  When 
51 .B find
52 examines or prints information a file, and the file is a symbolic
53 link, the information used shall be taken from the properties of the
54 symbolic link itself.  
56 .IP \-L
57 Follow symbolic links.  When 
58 .B find
59 examines or prints information about files, the information used shall
60 be taken from the properties of the file to which the link points, not
61 from the link itself (unless it is a broken symbolic link or 
62 .B find
63 is unable to examine the file to which the link points).  Use of this
64 option implies \-noleaf.  If you later use the \-P option, \-noleaf
65 will still be in effect.  If \-L is in effect and 
66 .B find 
67 discovers a symbolic link to a subdirectory during its search, 
68 the subdirectory pointed to by the symbolic link will be searched.
69 .IP
70 When the \-L option is in effect, the \-type predicate will always
71 match against the type of the file that a symbolic link points to
72 rather than the link itself (unless the symbolic link is broken).
73 Using \-L causes the \-lname and \-ilname predicates always to return
74 false.
76 .IP \-H
77 Do not follow symbolic links, except while processing the command
78 line arguments.  When
79 .B find
80 examines or prints information about files, the information used 
81 shall be taken from the properties of the symbolic link itself.   The
82 only exception to this behaviour is when a file specified on the
83 command line is a symbolic link, and the link can be resolved.  For
84 that situation, the information used is taken from whatever the link
85 points to (that is, the link is followed).  The information about the
86 link itself is used as a fallback if the file pointed to by the
87 symbolic link cannot be examined.  If \-H is in effect and one of the
88 paths specified on the command line is a symbolic link to a directory,
89 the contents of that directory will be examined (though of course
90 \-maxdepth 0 would prevent this).
92 If more than one of \-H, \-L and \-P is specified, each overrides the
93 others; the last one appearing on the command line takes effect.
94 Since it is the default, the \-P option should be considered to be in
95 effect unless either \-H or \-L is specified.
97 GNU 
98 .B find
99 frequently stats files during the processing of the command line
100 itself, before any searching has begun.  These options also affect how
101 those arguments are processed.  Specifically, there are a number of
102 tests that compare files listed on the command line against a file we
103 are currently considering.  In each case, the file specified on the
104 command line will have been examined and some of its properties will
105 have been saved.  If the named file is in fact a symbolic link, and
106 the \-P option is in effect (or if neither \-H nor \-L were
107 specified), the information used for the comparison will be taken from
108 the properties of the symbolic link.  Otherwise, it will be taken from
109 the properties of the file the link points to.  If
110 .B find 
111 cannot follow the link (for example because it has insufficient
112 privileges or the link points to a nonexistent file) the properties of
113 the link itself will be used.
115 When the \-H or \-L options are in effect, any symbolic links listed
116 as the argument of \-newer will be dereferenced, and the timestamp
117 will be taken from the file to which the symbolic link points.  The
118 same consideration applies to \-newerXY, \-anewer and \-cnewer.
120 The \-follow option has a similar effect to \-L, though it takes
121 effect at the point where it appears (that is, if \-L is not used but
122 \-follow is, any symbolic links appearing after \-follow on the
123 command line will be dereferenced, and those before it will not).
125 .IP "\-D debugoptions"
126 Print diagnostic information; this can be helpful to diagnose problems
127 with why
128 .B find 
129 is not doing what you want.  The list of debug options should be comma
130 separated.  Compatibility of the debug options is not guaranteed
131 between releases of findutils.  For a complete list of valid debug
132 options, see the output of
133 .B find \-D
134 .BR help .
135 Valid debug options include
137 .IP help
138 Explain the debugging options
139 .IP tree
140 Show the expression tree in its original and optimised form.
141 .IP stat
142 Print messages as files are examined with the 
143 .B stat 
144 and 
145 .B lstat 
146 system calls.  The 
147 .B find
148 program tries to minimise such calls.
149 .IP opt
150 Prints diagnostic information relating to the optimisation of the
151 expression tree; see the \-O option.
152 .IP rates
153 Prints a summary indicating how often each predicate succeeded or
154 failed.
156 .IP \-Olevel
157 Enables query optimisation.   The 
158 .B find 
159 program reorders tests to speed up execution while preserving the
160 overall effect; that is, predicates with side effects are not
161 reordered relative to each other.  The optimisations performed at each
162 optimisation level are as follows.
164 .IP 0
165 Equivalent to optimisation level 1.
166 .IP 1
167 This is the default optimisation level and corresponds to the
168 traditional behaviour.  Expressions are reordered so that tests based
169 only on the names of files (for example \-name 
170 and \-regex) are performed first.
171 .IP 2
172 Any \-type 
173 or \-xtype 
174 tests are performed after any tests based only on the names of files,
175 but before any tests that require information from the inode.  On many
176 modern versions of Unix, file types are returned by
177 .B readdir() 
178 and so these predicates are faster to evaluate than predicates which
179 need to stat the file first.
180 .IP 3
181 At this optimisation level, the full cost-based query optimiser is
182 enabled.  The order of tests is modified so that cheap (i.e. fast)
183 tests are performed first and more expensive ones are performed later,
184 if necessary.  Within each cost band, predicates are evaluated earlier
185 or later according to whether they are likely to succeed or not.  For \-o,
186 predicates which are likely to succeed are evaluated earlier, and for \-a,
187 predicates which are likely to fail are evaluated earlier.
190 The cost-based optimiser has a fixed idea of how likely any given test
191 is to succeed.  In some cases the probability takes account of the
192 specific nature of the test (for example, \-type f
193 is assumed to be more likely to succeed than \-type c).
194 The cost-based optimiser is currently being evaluated.   If it does
195 not actually improve the performance of 
196 .BR find ,
197 it will be removed again.  Conversely, optimisations that prove to be
198 reliable, robust and effective may be enabled at lower optimisation
199 levels over time.  However, the default behaviour (i.e. optimisation
200 level 1) will not be changed in the 4.3.x release series.  The
201 findutils test suite runs all the tests on 
202 .B find
203 at each optimisation level and ensures that the result is the same.
205 .SH EXPRESSIONS
206 The expression is made up of options (which affect overall operation
207 rather than the processing of a specific file, and always return
208 true), tests (which return a true or false value), and actions (which
209 have side effects and return a true or false value), all separated by
210 operators.  \-and is assumed where the operator is omitted.  
212 If the expression contains no actions other than \-prune, \-print is
213 performed on all files for which the expression is true.
215 .SS OPTIONS
217 All options always return true.  Except for \-daystart, \-follow and
218 \-regextype, the options affect all tests, including tests specified
219 before the option.  This is because the options are processed when the
220 command line is parsed, while the tests don't do anything until files
221 are examined.  The \-daystart, \-follow and \-regextype options are
222 different in this respect, and have an effect only on tests which
223 appear later in the command line.  Therefore, for clarity, it is best
224 to place them at the beginning of the expression.  A warning is issued
225 if you don't do this.
227 .IP \-d
228 A synonym for \-depth, for compatibility with FreeBSD, NetBSD, MacOS X and OpenBSD.
230 .IP \-daystart
231 Measure times (for \-amin, \-atime, \-cmin, \-ctime, \-mmin, and \-mtime)
232 from the beginning of today rather than from 24 hours ago.  This
233 option only affects tests which appear later on the command line.
235 .IP \-depth
236 Process each directory's contents before the directory itself.
238 .IP \-follow
239 Deprecated; use the \-L option instead.  Dereference symbolic links.
240 Implies \-noleaf.  The \-follow option affects only those tests which
241 appear after it on the command line.  Unless the \-H or \-L option has
242 been specified, the position of the \-follow option changes the
243 behaviour of the \-newer predicate; any files listed as the argument
244 of \-newer will be dereferenced if they are symbolic links.  The same
245 consideration applies to \-newerXY, \-anewer and \-cnewer.  Similarly,
246 the \-type predicate will always match against the type of the file
247 that a symbolic link points to rather than the link itself.  Using
248 \-follow causes the \-lname and \-ilname predicates always to return
249 false.
251 .IP "\-help, \-\-help"
252 Print a summary of the command-line usage of
253 .B find
254 and exit.
256 .IP \-ignore_readdir_race
257 Normally, \fBfind\fR will emit an error message when it fails to stat a file.
258 If you give this option and a file is deleted between the time \fBfind\fR 
259 reads the name of the file from the directory and the time it tries to stat 
260 the file, no error message will be issued.    This also applies to files
261 or directories whose names are given on the command line.  This option takes
262 effect at the time the command line is read, which means that you cannot search
263 one part of the filesystem with this option on and part of it with this option
264 off (if you need to do that, you will need to issue two \fBfind\fR commands
265 instead, one with the option and one without it).
267 .IP "\-maxdepth \fIlevels\fR"
268 Descend at most \fIlevels\fR (a non-negative integer) levels of
269 directories below the command line arguments.  `\-maxdepth 0' means
270 only apply the tests and actions to the command line arguments.
272 .IP "\-mindepth \fIlevels\fR"
273 Do not apply any tests or actions at levels less than \fIlevels\fR (a
274 non-negative integer).  `\-mindepth 1' means process all files except
275 the command line arguments.
277 .IP \-mount
278 Don't descend directories on other filesystems.  An alternate name for
279 \-xdev, for compatibility with some other versions of
280 .BR find .
282 .IP \-noignore_readdir_race
283 Turns off the effect of \-ignore_readdir_race. 
285 .IP "\-noleaf"
286 Do not optimize by assuming that directories contain 2 fewer
287 subdirectories than their hard link count.  This option is needed when
288 searching filesystems that do not follow the Unix directory-link
289 convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount
290 points.  Each directory on a normal Unix filesystem has at least 2
291 hard links: its name and its `.'  entry.  Additionally, its
292 subdirectories (if any) each have a `..'  entry linked to that
293 directory.  When
294 .B find
295 is examining a directory, after it has statted 2 fewer subdirectories
296 than the directory's link count, it knows that the rest of the entries
297 in the directory are non-directories (`leaf' files in the directory
298 tree).  If only the files' names need to be examined, there is no need
299 to stat them; this gives a significant increase in search speed.
301 .IP "\-regextype \fItype\fR"
302 Changes the regular expression syntax understood by 
303 .B \-regex
304 and 
305 .B \-iregex
306 tests which occur later on the command line.  Currently-implemented
307 types are emacs (this is the default), posix-awk, posix-basic,
308 posix-egrep and posix-extended.
310 .IP "\-version, \-\-version"
311 Print the \fBfind\fR version number and exit.
313 .IP "\-warn, \-nowarn"
314 Turn warning messages on or off.  These warnings apply only to the
315 command line usage, not to any conditions that 
316 .B find 
317 might encounter when it searches directories.  The default behaviour
318 corresponds to \-warn if standard input is a tty, and to \-nowarn
319 otherwise.
321 .IP \-xdev
322 Don't descend directories on other filesystems.
324 .SS TESTS
325 Some tests, for example
326 .B \-newerXY
327 and 
328 .BR -samefile ,
329 allow comparison between the file currently being examined and some
330 reference file specified on the command line.  When these tests are
331 used, the interpretation of the reference file is determined by the 
332 options 
333 .BR \-H , 
334 .B \-L 
335 and 
336 .B \-P
337 and any previous 
338 .BR \-follow ,
339 but the reference file is only examined once, at the time the command
340 line is parsed.  If the reference file cannot be examined (for
341 example, the 
342 .BR stat (2) 
343 system call fails for it), an error message is issued, and 
344 .B find
345 exits with a nonzero status.
347 Numeric arguments can be specified as
348 .IP \fI+n\fP
349 for greater than
350 .IR n ,
351 .IP \fI\-n\fP
352 for less than
353 .IR n ,
354 .IP \fIn\fP
355 for exactly
356 .IR n .
359 .IP "\-amin \fIn\fR"
360 File was last accessed \fIn\fR minutes ago.
362 .IP "\-anewer \fIfile\fR"
363 File was last accessed more recently than \fIfile\fR was modified.  If
364 \fIfile\fR is a symbolic link and the \-H option or the \-L option is
365 in effect, the access time of the file it points to is always
366 used.
368 .IP "\-atime \fIn\fR"
369 File was last accessed \fIn\fR*24 hours ago.  
370 When find figures out how many 24-hour periods ago the file 
371 was last accessed, any fractional part is ignored, so to match 
372 .B \-atime 
373 .BR +1 ,
374 a file has to have been accessed at least 
375 .I two
376 days ago.
378 .IP "\-cmin \fIn\fR"
379 File's status was last changed \fIn\fR minutes ago.
381 .IP "\-cnewer \fIfile\fR"
382 File's status was last changed more recently than \fIfile\fR was
383 modified.  If \fIfile\fR is a symbolic link and the \-H option or the
384 \-L option is in effect, the status-change time of the file it points
385 to is always used.
387 .IP "\-ctime \fIn\fR"
388 File's status was last changed \fIn\fR*24 hours ago.
389 See the comments for 
390 .B \-atime 
391 to understand how rounding affects the interpretation of file status
392 change times.
394 .IP \-empty
395 File is empty and is either a regular file or a directory.
397 .IP \-executable
398 Matches files which are executable and directories which are
399 searchable (in a file name resolution sense).  This takes into account
400 access control lists and other permissions artefacts which the
401 .B \-perm 
402 test ignores.  This test makes use of the
403 .BR access (2)
404 system call, and so can be fooled by NFS servers which do UID
405 mapping (or root-squashing), since many systems implement 
406 .BR access (2) 
407 in the client's kernel and so cannot make use of the UID mapping
408 information held on the server.  Because this test is based only on
409 the result of the 
410 .BR access (2)
411 system call, there is no guarantee that a file for which this test
412 succeeds can actually be executed.
414 .IP \-false
415 Always false.
417 .IP "\-fstype \fItype\fR"
418 File is on a filesystem of type \fItype\fR.  The valid filesystem
419 types vary among different versions of Unix; an incomplete list of
420 filesystem types that are accepted on some version of Unix or another
421 is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K.  You can use \-printf
422 with the %F directive to see the types of your filesystems.
424 .IP "\-gid \fIn\fR"
425 File's numeric group ID is \fIn\fR.
427 .IP "\-group \fIgname\fR"
428 File belongs to group \fIgname\fR (numeric group ID allowed).
430 .IP "\-ilname \fIpattern\fR"
431 Like \-lname, but the match is case insensitive.
432 If the \-L option or the \-follow option is in effect, this test 
433 returns false unless the symbolic link is broken.
435 .IP "\-iname \fIpattern\fR"
436 Like \-name, but the match is case insensitive.  For example, the
437 patterns `fo*' and `F??' match the file names `Foo', `FOO', `foo',
438 `fOo', etc.   In these patterns, unlike filename expansion by the
439 shell, an initial '.' can be matched by `*'.  That is, 
440 .B find \-name *bar 
441 will match the file `.foobar'.   Please note that you should quote
442 patterns as a matter of course, otherwise the shell will expand any
443 wildcard characters in them.
445 .IP "\-inum \fIn\fR"
446 File has inode number \fIn\fR.  It is normally easier to use the 
447 .B \-samefile
448 test instead.
450 .IP "\-ipath \fIpattern\fR"
451 Behaves in the same way as \-iwholename.  This option is deprecated,
452 so please do not use it.
454 .IP "\-iregex \fIpattern\fR"
455 Like \-regex, but the match is case insensitive.
457 .IP "\-iwholename \fIpattern\fR"
458 Like \-wholename, but the match is case insensitive.
460 .IP "\-links \fIn\fR"
461 File has \fIn\fR links.
463 .IP "\-lname \fIpattern\fR"
464 File is a symbolic link whose contents match shell pattern
465 \fIpattern\fR.  The metacharacters do not treat `/' or `.' specially.
466 If the \-L option or the \-follow option is in effect, this test 
467 returns false unless the symbolic link is broken.
469 .IP "\-mmin \fIn\fR"
470 File's data was last modified \fIn\fR minutes ago.
472 .IP "\-mtime \fIn\fR"
473 File's data was last modified \fIn\fR*24 hours ago.
474 See the comments for 
475 .B \-atime 
476 to understand how rounding affects the interpretation of file
477 modification times.
479 .IP "\-name \fIpattern\fR"
480 Base of file name (the path with the leading directories removed)
481 matches shell pattern \fIpattern\fR.  The metacharacters (`*', `?',
482 and `[]') match a `.' at the start of the base name (this is a change
483 in findutils-4.2.2; see section STANDARDS CONFORMANCE below).  To ignore a
484 directory and the files under it, use \-prune; see an example in the
485 description of \-wholename.  Braces are not recognised as being
486 special, despite the fact that some shells including Bash imbue braces
487 with a special meaning in shell patterns.  The filename matching is
488 performed with the use of the
489 .BR fnmatch (3) 
490 library function.   Don't forget to enclose the pattern in quotes 
491 in order to protect it from expansion by the shell.
493 .IP "\-newer \fIfile\fR"
494 File was modified more recently than \fIfile\fR.  If \fIfile\fR is a
495 symbolic link and the \-H option or the \-L option is in effect, the
496 modification time of the file it points to is always used.
498 .IP "\-newerXY \fIreference\fR"
499 Compares the timestamp of the current file with \fIreference\fR.  
500 The 
501 .I reference 
502 argument is normally the name of a file (and one of its timestamps is
503 used for the comparison) but it may also be a string describing an
504 absolute time.  
505 .I X 
506 and 
507 .I Y 
508 are placeholders for other letters, and these letters select which
509 time belonging to 
510 how 
511 .I reference 
512 is used for the comparison.
518 llw(2i).
519 a       The access time of the file \fIreference\fR 
520 B       The birth time of the file \fIreference\fR
521 c       The inode status change time of \fIreference\fR
522 m       The modification time of the file \fIreference\fR
523 t       \fIreference\fR is interpreted directly as a time
526 Some combinations are invalid; for example, it is invalid for
527 .I X 
528 to be 
529 .IR t .
530 Some combinations are not implemented on all systems; for example 
531 .I B
532 is not supported on all systems.  If an invalid or unsupported
533 combination of 
534 .I XY 
535 is specified, a fatal error results.  Time specifications are
536 interpreted as for the argument to the \-d option of GNU 
537 .BR date .
538 If you try to use the birth time of a reference file, and the birth
539 time cannot be determined, a fatal error message results.  If you
540 specify a test which refers to the birth time of files being examined,
541 this test will fail for any files where the birth time is unknown.
543 .IP \-nogroup
544 No group corresponds to file's numeric group ID.
546 .IP \-nouser
547 No user corresponds to file's numeric user ID.
549 .IP "\-path \fIpattern\fR"
550 See \-wholename.   The predicate \-path is also supported by HP-UX 
551 .BR find .
553 .IP "\-perm \fImode\fR"
554 File's permission bits are exactly \fImode\fR (octal or symbolic).
555 Since an exact match is required, if you want to use this form for
556 symbolic modes, you may have to specify a rather complex mode string.
557 For example `\-perm g=w' will only match files which have mode 0020
558 (that is, ones for which group write permission is the only permission
559 set).  It is more likely that you will want to use the `/' or `-'
560 forms, for example `\-perm \-g=w', which matches any file with group
561 write permission.  See the
562 .B EXAMPLES 
563 section for some illustrative examples.
565 .IP "\-perm \-\fImode\fR"
566 All of the permission bits \fImode\fR are set for the file.
567 Symbolic modes are accepted in this form, and this is usually the way
568 in which would want to use them.  You must specify `u', `g' or `o' if
569 you use a symbolic mode.   See the 
570 .B EXAMPLES 
571 section for some illustrative examples.
573 .IP "\-perm /\fImode\fR"
574 Any of the permission bits \fImode\fR are set for the file.  Symbolic
575 modes are accepted in this form.  You must specify `u', `g' or `o' if
576 you use a symbolic mode.  See the
577 .B EXAMPLES 
578 section for some illustrative examples.  If no permission bits in 
579 .I mode
580 are set, this test currently matches no files.  However, it will soon
581 be changed to match any file (the idea is to be more consistent with
582 the behaviour of 
583 .B \-perm 
584 .BR \-000 ).
586 .IP "\-perm +\fImode\fR"
587 Deprecated, old way of searching for files with any of the permission
588 bits in \fImode\fR set.  You should use
589 .B \-perm \fI/mode\fR
590 instead. Trying to use the `+' syntax with symbolic modes will yield
591 surprising results.  For example, `+u+x' is a valid symbolic mode
592 (equivalent to +u,+x, i.e. 0111) and will therefore not be evaluated
594 .B \-perm +\fImode\fR
595 but instead as the exact mode specifier
596 .B \-perm \fImode\fR
597 and so it matches files with exact permissions 0111 instead of files with any
598 execute bit set.  If you found this paragraph confusing, you're not
599 alone - just use 
600 .B \-perm /\fImode\fR.
601 This form of the 
602 .B \-perm
603 test is deprecated because the POSIX specification requires the
604 interpretation of a leading `+' as being part of a symbolic mode, and
605 so we switched to using `/' instead.
607 .IP \-readable
608 Matches files which are readable.  This takes into account access
609 control lists and other permissions artefacts which the
610 .B \-perm 
611 test ignores.  This test makes use of the
612 .BR access (2)
613 system call, and so can be fooled by NFS servers which do UID
614 mapping (or root-squashing), since many systems implement 
615 .BR access (2) 
616 in the client's kernel and so cannot make use of the UID mapping
617 information held on the server.
619 .IP "\-regex \fIpattern\fR"
620 File name matches regular expression \fIpattern\fR.  This is a match
621 on the whole path, not a search.  For example, to match a file named
622 `./fubar3', you can use the regular expression `.*bar.' or `.*b.*3',
623 but not `f.*r3'.  The regular expressions understood by 
624 .B find 
625 are by default Emacs Regular Expressions, but this can be
626 changed with the 
627 .B \-regextype 
628 option.
630 .IP "\-samefile \fIname\fR"
631 File refers to the same inode as \fIname\fR.   When \-L is in effect,
632 this can include symbolic links.
634 .IP "\-size \fIn\fR[cwbkMG]"
635 File uses \fIn\fP units of space.  The following suffixes 
636 can be used:
638 .IP `b' 
639 for 512-byte blocks (this is the default if no suffix is used)
640 .IP `c' 
641 for bytes
642 .IP `w' 
643 for two-byte words
644 .IP `k' 
645 for Kilobytes (units of 1024 bytes)
646 .IP `M' 
647 for Megabytes (units of 1048576 bytes)
648 .IP `G' 
649 for Gigabytes (units of 1073741824 bytes)
652 The size does not count indirect blocks, but it does count blocks in
653 sparse files that are not actually allocated.  Bear in mind that the
654 `%k' and `%b' format specifiers of \-printf handle sparse files
655 differently.  The `b' suffix always denotes 512-byte blocks and never
656 1 Kilobyte blocks, which is different to the behaviour of \-ls.
658 .IP \-true
659 Always true.
661 .IP "\-type \fIc\fR"
662 File is of type \fIc\fR:
664 .IP b
665 block (buffered) special
666 .IP c
667 character (unbuffered) special
668 .IP d
669 directory
670 .IP p
671 named pipe (FIFO)
672 .IP f
673 regular file
674 .IP l
675 symbolic link; this is never true if the \-L option or the \-follow
676 option is in effect, unless the symbolic link is broken.  If you want
677 to search for symbolic links when \-L is in effect, use \-xtype.
678 .IP s
679 socket
680 .IP D
681 door (Solaris)
683 .IP "\-uid \fIn\fR"
684 File's numeric user ID is \fIn\fR.
686 .IP "\-used \fIn\fR"
687 File was last accessed \fIn\fR days after its status was last changed.
689 .IP "\-user \fIuname\fR"
690 File is owned by user \fIuname\fR (numeric user ID allowed).
692 .IP "\-wholename \fIpattern\fR"
693 File name matches shell pattern \fIpattern\fR.  The metacharacters do
694 not treat `/' or `.' specially; so, for example,
696 .in +1i
697 find . \-wholename "./sr*sc"
699 .in -1i
700 will print an entry for a directory called `./src/misc' (if one
701 exists).  To ignore a whole directory tree, use \-prune rather than
702 checking every file in the tree.  For example, to skip the
703 directory `src/emacs' and all files and directories under it, and
704 print the names of the other files found, do something like this:
706 .in +1i
707 find . \-wholename ./src/emacs \-prune \-o \-print
709 .in -1i
711 .IP "\-writable"
712 Matches files which are writable.  This takes into account access
713 control lists and other permissions artefacts which the
714 .B \-perm 
715 test ignores.  This test makes use of the
716 .BR access (2)
717 system call, and so can be fooled by NFS servers which do UID
718 mapping (or root-squashing), since many systems implement 
719 .BR access (2) 
720 in the client's kernel and so cannot make use of the UID mapping
721 information held on the server.
723 .IP "\-xtype \fIc\fR"
724 The same as \-type unless the file is a symbolic link.  For symbolic
725 links: if the \-H or \-P option was specified, true if the file is a
726 link to a file of type \fIc\fR; if the \-L option has been given, true
727 if \fIc\fR is `l'.  In other words, for symbolic links, \-xtype checks
728 the type of the file that \-type does not check.
730 .SS ACTIONS
731 .IP "\-delete\fR"
732 Delete files; true if removal succeeded.  If the removal failed, an
733 error message is issued.  Use of this action automatically turns on
734 the `\-depth' option.
736 .IP "\-exec \fIcommand\fR ;"
737 Execute \fIcommand\fR; true if 0 status is returned.  All following
738 arguments to
739 .B find
740 are taken to be arguments to the command until an argument consisting
741 of `;' is encountered.  The string `{}' is replaced by the current
742 file name being processed everywhere it occurs in the arguments to the
743 command, not just in arguments where it is alone, as in some versions
745 .BR find .
746 Both of these constructions might need to be escaped (with a `\e') or
747 quoted to protect them from expansion by the shell.  See the
748 .B EXAMPLES
749 section for examples of the use of the `\-exec' option.  The specified
750 command is run once for each matched file.
751 The command is executed in the starting directory.   There are
752 unavoidable security problems surrounding use of the \-exec action;
753 you should use the \-execdir option instead.  
755 .IP "\-exec \fIcommand\fR {} +"
756 This variant of the \-exec action runs the specified command on the
757 selected files, but the command line is built by appending each
758 selected file name at the end; the total number of invocations of the
759 command will be much less than the number of matched files.  The
760 command line is built in much the same way that
761 .B xargs
762 builds its command lines.  Only one instance of `{}' is allowed within
763 the command.  The command is executed in the starting directory.
765 .IP "\-execdir \fIcommand\fR ;"
766 .IP "\-execdir \fIcommand\fR {} +"
767 Like \-exec, but the specified command is run from the subdirectory
768 containing the matched file, which is not normally the directory in
769 which you started 
770 .BR find .
771 This a much more secure method for invoking commands, as it avoids
772 race conditions during resolution of the paths to the matched files.
773 As with the \-exec action, the `+' form of \-execdir will build a
774 command line to process more than one matched file, but any given
775 invocation of
776 .I command 
777 will only list files that exist in the same subdirectory.  If you use
778 this option, you must ensure that your 
779 .B $PATH
780 environment variable does not reference the current directory;
781 otherwise, an attacker can run any commands they like by leaving an
782 appropriately-named file in a directory in which you will run
783 \-execdir.
785 .IP "\-fls \fIfile\fR"
786 True; like \-ls but write to \fIfile\fR like \-fprint.
787 The output file is always created, even if the predicate is never
788 matched.  
789 See the
790 .B UNUSUAL FILENAMES
791 section for information about how unusual characters in filenames are handled.
793 .IP "\-fprint \fIfile\fR"
794 True; print the full file name into file \fIfile\fR.  If \fIfile\fR
795 does not exist when \fBfind\fR is run, it is created; if it does
796 exist, it is truncated.  The file names ``/dev/stdout'' and
797 ``/dev/stderr'' are handled specially; they refer to the standard
798 output and standard error output, respectively.
799 The output file is always created, even if the predicate is never matched.
800 See the
801 .B UNUSUAL FILENAMES
802 section for information about how unusual characters in filenames are handled.
804 .IP "\-fprint0 \fIfile\fR"
805 True; like \-print0 but write to \fIfile\fR like \-fprint.
806 The output file is always created, even if the predicate is never matched.
807 See the
808 .B UNUSUAL FILENAMES
809 section for information about how unusual characters in filenames are handled.
811 .IP "\-fprintf \fIfile\fR \fIformat\fR"
812 True; like \-printf but write to \fIfile\fR like \-fprint.
813 The output file is always created, even if the predicate is never matched.
814 See the
815 .B UNUSUAL FILENAMES
816 section for information about how unusual characters in filenames are handled.
818 .IP \-ls
819 True; list current file in `ls \-dils' format on standard output.
820 The block counts are of 1K blocks, unless the environment variable
821 POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
822 See the
823 .B UNUSUAL FILENAMES
824 section for information about how unusual characters in filenames are handled.
826 .IP "\-ok \fIcommand\fR ;"
827 Like \-exec but ask the user first (on the standard input); if the
828 response does not start with `y' or `Y', do not run the command, and
829 return false.  If the command is run, its standard input is redirected
830 from
831 .BR /dev/null .
833 .IP "\-okdir \fIcommand\fR ;"
834 Like \-execdir but ask the user first (on the standard input); if the
835 response does not start with `y' or `Y', do not run the command, and
836 return false.  If the command is run, its standard input is redirected
837 from
838 .BR /dev/null .
840 .IP \-print
841 True; print the full file name on the standard output, followed by a
842 newline.   If you are piping the output of 
843 .B find 
844 into another program and there is the faintest possibility that the files 
845 which you are searching for might contain a newline, then you should 
846 seriously consider using the `\-print0' option instead of `\-print'.
847 See the
848 .B UNUSUAL FILENAMES
849 section for information about how unusual characters in filenames are handled.
851 .IP \-print0
852 True; print the full file name on the standard output, followed by a
853 null character (instead of the newline character that `\-print' uses).
854 This allows file names that contain newlines or other types of white
855 space to be correctly interpreted by programs that process the
856 \fBfind\fR output.  This option corresponds to the `\-0' option of
857 .BR xargs .
859 .IP "\-printf \fIformat\fR"
860 True; print \fIformat\fR on the standard output, interpreting `\e'
861 escapes and `%' directives.  Field widths and precisions can be
862 specified as with the `printf' C function.  Please note that many of
863 the fields are printed as %s rather than %d, and this may mean that
864 flags don't work as you might expect.  This also means that the `\-'
865 flag does work (it forces fields to be left-aligned).  Unlike \-print,
866 \-printf does not add a newline at the end of the string.  The escapes
867 and directives are:
869 .IP \ea
870 Alarm bell.
871 .IP \eb
872 Backspace.
873 .IP \ec
874 Stop printing from this format immediately and flush the output.
875 .IP \ef
876 Form feed.
877 .IP \en
878 Newline.
879 .IP \er
880 Carriage return.
881 .IP \et
882 Horizontal tab.
883 .IP \ev
884 Vertical tab.
885 .IP \e\0
886 ASCII NUL.
887 .IP \e\e
888 A literal backslash (`\e').
889 .IP \eNNN
890 The character whose ASCII code is NNN (octal).
892 A `\e' character followed by any other character is treated as an
893 ordinary character, so they both are printed.
894 .IP %%
895 A literal percent sign.
896 .IP %a
897 File's last access time in the format returned by the C `ctime' function.
898 .IP %A\fIk\fP
899 File's last access time in the format specified by \fIk\fR, which is
900 either `@' or a directive for the C `strftime' function.  The possible
901 values for \fIk\fR are listed below; some of them might not be
902 available on all systems, due to differences in `strftime' between
903 systems.  
905 .IP @
906 seconds since Jan. 1, 1970, 00:00 GMT, with fractional part.
908 Time fields:
909 .IP H
910 hour (00..23)
911 .IP I
912 hour (01..12)
913 .IP k
914 hour ( 0..23)
915 .IP l
916 hour ( 1..12)
917 .IP M
918 minute (00..59)
919 .IP p
920 locale's AM or PM
921 .IP r
922 time, 12-hour (hh:mm:ss [AP]M)
923 .IP S
924 Second (00.00 .. 61.00).  There is a fractional part.
925 .IP T
926 time, 24-hour (hh:mm:ss)
927 .IP +
928 Date and time, separated by `+', for example
929 `2004\-04\-28+22:22:05.0'.  This is a GNU extension.  The time is
930 given in the current timezone (which may be affected by setting the TZ
931 environment variable).  The seconds field includes a fractional part.
932 .IP X
933 locale's time representation (H:M:S)
934 .IP Z
935 time zone (e.g., EDT), or nothing if no time zone is determinable
937 Date fields:
938 .IP a
939 locale's abbreviated weekday name (Sun..Sat)
940 .IP A
941 locale's full weekday name, variable length (Sunday..Saturday)
942 .IP b
943 locale's abbreviated month name (Jan..Dec)
944 .IP B
945 locale's full month name, variable length (January..December)
946 .IP c
947 locale's date and time (Sat Nov 04 12:02:33 EST 1989).  The format is
948 the same as for 
949 .BR ctime (3)
950 and so to preserve compatibility with that format, there is no fractional part
951 in the seconds field.
952 .IP d
953 day of month (01..31)
954 .IP D
955 date (mm/dd/yy)
956 .IP h
957 same as b
958 .IP j
959 day of year (001..366)
960 .IP m
961 month (01..12)
962 .IP U
963 week number of year with Sunday as first day of week (00..53)
964 .IP w
965 day of week (0..6)
966 .IP W
967 week number of year with Monday as first day of week (00..53)
968 .IP x
969 locale's date representation (mm/dd/yy)
970 .IP y
971 last two digits of year (00..99)
972 .IP Y
973 year (1970...)
975 .IP %b
976 The amount of disk space used for this file in 512-byte blocks. Since disk
977 space is allocated in multiples of the filesystem block size this is usually
978 greater than %s/512, but it can also be smaller if the file is a sparse file.
979 .IP %c
980 File's last status change time in the format returned by the C `ctime'
981 function.
982 .IP %C\fIk\fP
983 File's last status change time in the format specified by \fIk\fR,
984 which is the same as for %A.
985 .IP %d
986 File's depth in the directory tree; 0 means the file is a command line
987 argument.
988 .IP %D
989 The device number on which the file exists (the st_dev field of struct
990 stat), in decimal.
991 .IP %f
992 File's name with any leading directories removed (only the last element).
993 .IP %F
994 Type of the filesystem the file is on; this value can be used for
995 \-fstype.
996 .IP %g
997 File's group name, or numeric group ID if the group has no name.
998 .IP %G
999 File's numeric group ID.
1000 .IP %h
1001 Leading directories of file's name (all but the last element).
1002 If the file name contains no slashes (since it is in the current 
1003 directory) the %h specifier expands to ".".
1004 .IP %H
1005 Command line argument under which file was found.
1006 .IP %i
1007 File's inode number (in decimal).
1008 .IP %k
1009 The amount of disk space used for this file in 1K blocks. Since disk space is
1010 allocated in multiples of the filesystem block size this is usually greater
1011 than %s/1024, but it can also be smaller if the file is a sparse file.
1012 .IP %l
1013 Object of symbolic link (empty string if file is not a symbolic link).
1014 .IP %m
1015 File's permission bits (in octal).  This option uses the `traditional'
1016 numbers which most Unix implementations use, but if your particular 
1017 implementation uses an unusual ordering of octal permissions bits, you
1018 will see a difference between the actual value of the file's mode and
1019 the output of %m.   Normally you will want to have a leading
1020 zero on this number, and to do this, you should use the 
1021 .B #
1022 flag (as in, for example, `%#m').
1023 .IP %M 
1024 File's permissions (in symbolic form, as for 
1025 .BR ls ).  
1026 This directive is supported in findutils 4.2.5 and later.
1027 .IP %n
1028 Number of hard links to file.
1029 .IP %p
1030 File's name.
1031 .IP %P
1032 File's name with the name of the command line argument under which
1033 it was found removed.
1034 .IP %s
1035 File's size in bytes.
1036 .IP %S 
1037 File's sparseness.  This is calculated as (BLOCKSIZE*st_blocks /
1038 st_size).  The exact value you will get for an ordinary file of a
1039 certain length is system-dependent.  However, normally sparse files
1040 will have values less than 1.0, and files which use indirect blocks
1041 may have a value which is greater than 1.0.   The value used for
1042 BLOCKSIZE is system-dependent, but is usually 512 bytes.   If the file
1043 size is zero, the value printed is undefined.  On systems which lack
1044 support for st_blocks, a file's sparseness is assumed to be 1.0.
1045 .IP %t
1046 File's last modification time in the format returned by the C `ctime'
1047 function.
1048 .IP %T\fIk\fP
1049 File's last modification time in the format specified by \fIk\fR, 
1050 which is the same as for %A.
1051 .IP %u
1052 File's user name, or numeric user ID if the user has no name.
1053 .IP %U
1054 File's numeric user ID.
1055 .IP %y
1056 File's type (like in ls \-l), U=unknown type (shouldn't happen)
1057 .IP %Y
1058 File's type (like %y), plus follow symlinks: L=loop, N=nonexistent
1060 A `%' character followed by any other character is discarded, but the
1061 other character is printed (don't rely on this, as further format
1062 characters may be introduced).  A `%' at the end of the format
1063 argument causes undefined behaviour since there is no following
1064 character.  In some locales, it may hide your door keys, while in
1065 others it may remove the final page from the novel you are reading.
1067 The %m and %d directives support the 
1068 .B #
1070 .B 0 
1071 and 
1072 .B + 
1073 flags, but the other directives do not, even if they
1074 print numbers.  Numeric directives that do not support these flags
1075 include 
1076 .BR G , 
1077 .BR U , 
1078 .BR b , 
1079 .BR D , 
1080 .B  k 
1081 and 
1082 .BR n .
1083 The `\-' format flag is supported and changes the alignment of a field
1084 from right-justified (which is the default) to left-justified.
1086 See the
1087 .B UNUSUAL FILENAMES
1088 section for information about how unusual characters in filenames are handled.
1092 .IP \-prune
1093 If \-depth is not given, true; if the file is a directory, do not descend
1094 into it.
1096 If \-depth is given, false; no effect.
1098 .IP "\-quit"
1099 Exit immediately.  No child processes will be left running, but no more
1100 paths specified on the command line will be processed.  For example,
1101 .B find /tmp/foo /tmp/bar \-print \-quit
1102 will print only
1103 .BR /tmp/foo .
1104 Any command lines which have been built up with
1105 .B \-execdir ... {} +
1106 will be invoked before 
1107 .B find
1108 exits.   The exit status may or may not be zero, depending on whether
1109 an error has already occurred.  
1111 .SS UNUSUAL FILENAMES
1112 Many of the actions of 
1113 .B find
1114 result in the printing of data which is under the control of other
1115 users.  This includes file names, sizes, modification times and so
1116 forth.  File names are a potential problem since they can contain any
1117 character except `\e0' and `/'.  Unusual characters in file names can
1118 do unexpected and often undesirable things to your terminal (for
1119 example, changing the settings of your function keys on some
1120 terminals).  Unusual characters are handled differently by various
1121 actions, as described below.
1123 .IP "\-print0, \-fprint0\"
1124 Always print the exact filename, unchanged, even if the output is
1125 going to a terminal.
1127 .IP "\-ls, \-fls"
1128 Unusual characters are always escaped.  White space, backslash, and
1129 double quote characters are printed using C-style escaping (for
1130 example `\ef', `\e"').  Other unusual characters are printed using an
1131 octal escape.  Other printable characters (for \-ls and \-fls these are
1132 the characters between octal 041 and 0176) are printed as-is.
1134 .IP "\-printf, \-fprintf"
1135 If the output is not going to a terminal, it is printed as-is.
1136 Otherwise, the result depends on which directive is in use.  The
1137 directives %D, %F, %g, %G, %H, %Y, and %y expand to values which are
1138 not under control of files' owners, and so are printed as-is.  The
1139 directives %a, %b, %c, %d, %i, %k, %m, %M, %n, %s, %t, %u and %U have
1140 values which are under the control of files' owners but which cannot
1141 be used to send arbitrary data to the terminal, and so these are
1142 printed as-is.  The directives %f, %h, %l, %p and %P are quoted.  This
1143 quoting is performed in the same way as for GNU
1144 .BR ls .   
1145 This is not the same quoting mechanism as the one used for  \-ls and
1146 \-fls.   If you are able to decide what format to use for the output 
1147 of 
1148 .B find
1149 then it is normally better to use `\e0' as a terminator
1150 than to use newline, as file names can contain white space and newline
1151 characters.
1153 .IP "\-print, \-fprint"
1154 Quoting is handled in the same way as for \-printf and \-fprintf.
1155 If you are using 
1156 .B find
1157 in a script or in a situation where the matched files might have
1158 arbitrary names, you should consider using \-print0 instead of
1159 \-print.
1161 The \-ok and \-okdir actions print the current filename as-is.  This
1162 may change in a future release.
1163 .SS OPERATORS
1165 Listed in order of decreasing precedence:
1167 .IP "( \fIexpr\fR )"
1168 Force precedence.  Since parentheses are special to the shell, you
1169 will normally need to quote them.  Many of the examples in this manual
1170 page use backslashes for this purpose: `\e(...\e)' instead of `(...)'.
1172 .IP "! \fIexpr\fR"
1173 True if \fIexpr\fR is false.  This character will also usually need
1174 protection from interpretation by the shell.
1176 .IP "\-not \fIexpr\fR"
1177 Same as ! \fIexpr\fR, but not POSIX compliant.
1179 .IP "\fIexpr1 expr2\fR"
1180 Two expressions in a row are taken to be joined with an 
1181 implied "and"; \fIexpr2\fR is not evaluated if \fIexpr1\fR is false.
1183 .IP "\fIexpr1\fR \-a \fIexpr2\fR"
1184 Same as \fIexpr1 expr2\fR.
1186 .IP "\fIexpr1\fR \-and \fIexpr2\fR"
1187 Same as \fIexpr1 expr2\fR, but not POSIX compliant.
1189 .IP "\fIexpr1\fR \-o \fIexpr2\fR"
1190 Or; \fIexpr2\fR is not evaluated if \fIexpr1\fR is true.
1192 .IP "\fIexpr1\fR \-or \fIexpr2\fR"
1193 Same as \fIexpr1\fR \-o \fIexpr2\fR, but not POSIX compliant.
1195 .IP "\fIexpr1\fR , \fIexpr2\fR"
1196 List; both \fIexpr1\fR and \fIexpr2\fR are always evaluated.  The
1197 value of \fIexpr1\fR is discarded; the value of the list is the value
1198 of \fIexpr2\fR. The comma operator can be useful for searching for
1199 several different types of thing, but traversing the filesystem
1200 hierarchy only once.  The
1201 .B \-fprintf  
1202 action can be used to list the various matched items into several
1203 different output files.
1206 .SH "STANDARDS CONFORMANCE"
1207 The following options are specified in the POSIX standard 
1208 (IEEE Std 1003.1, 2003 Edition):
1210 .IP "\-H"
1211 This option is supported.
1213 .IP "\-L"
1214 This option is supported.
1216 .IP "\-name"
1217 This option is supported, but POSIX conformance depends on the 
1218 POSIX conformance of the system's 
1219 .BR fnmatch (3) 
1220 library function.  As of findutils-4.2.2, shell metacharacters
1221 (`*', `?' or `[]' for example) will match a leading `.', because 
1222 IEEE PASC interpretation 126 requires this.   This is a change from
1223 previous versions of findutils.
1225 .IP "\-type"
1226 Supported.   POSIX specifies `b', `c', `d', `l', `p', `f' and `s'.
1227 GNU find also supports `D', representing a Door, where the OS provides these.
1229 .IP "\-ok"
1230 Supported.   Interpretation of the response is not locale-dependent
1231 (see ENVIRONMENT VARIABLES).
1233 .IP "\-newer"
1234 Supported.  If the file specified is a symbolic link, it is always
1235 dereferenced.  This is a change from previous behaviour, which used to 
1236 take the relevant time from the symbolic link; see the HISTORY section
1237 below.
1239 .IP "Other predicates"
1240 The predicates
1241 `\-atime',
1242 `\-ctime',
1243 `\-depth',
1244 `\-group',
1245 `\-links',
1246 `\-mtime',
1247 `\-nogroup',
1248 `\-nouser',
1249 `\-perm',
1250 `\-print',
1251 `\-prune',
1252 `\-size',
1253 `\-user' and 
1254 `\-xdev',
1255 are all supported.
1258 The POSIX standard specifies parentheses `(', `)', negation `!' and the
1259 `and' and `or' operators (`\-a', `\-o').   
1261 All other options, predicates, expressions and so forth are extensions 
1262 beyond the POSIX standard.  Many of these extensions are not unique to 
1263 GNU find, however.
1265 The POSIX standard requires that 
1266 .B find 
1267 detects loops:
1269 The 
1270 .B find
1271 utility shall detect infinite loops; that is, entering a
1272 previously visited directory that is an ancestor of the last file
1273 encountered. When it detects an infinite loop, find shall write a
1274 diagnostic message to standard error and shall either recover its
1275 position in the hierarchy or terminate.
1277 GNU 
1278 .B find 
1279 complies with these requirements.  The link count of
1280 directories which contain entries which are hard links to an ancestor
1281 will often be lower than they otherwise should be.  This can mean that
1282 GNU find will sometimes optimise away the visiting of a subdirectory
1283 which is actually a link to an ancestor.  Since
1284 .B find
1285 does not actually enter such a subdirectory, it is allowed to avoid
1286 emitting a diagnostic message.  Although this behaviour may be
1287 somewhat confusing, it is unlikely that anybody actually depends on
1288 this behaviour.  If the leaf optimisation has been turned off with
1289 .BR \-noleaf ,
1290 the directory entry will always be examined and the diagnostic message
1291 will be issued where it is appropriate.  Symbolic links cannot be used
1292 to create filesystem cycles as such, but if the \-L option or the
1293 \-follow option is in use, a diagnostic message is issued when 
1294 .B find 
1295 encounters a loop of symbolic links.  As with loops containing hard
1296 links, the leaf optimisation will often mean that 
1297 .B find
1298 knows that it doesn't need to call 
1299 .I stat()
1301 .I chdir() 
1302 on the symbolic link, so this diagnostic is frequently not necessary.
1304 The \-d option is supported for compatibility with various BSD systems,
1305 but you should use the POSIX-compliant option \-depth instead.
1307 The POSIXLY_CORRECT environment variable does not affect the behaviour
1308 of the \-regex or \-iregex tests because those tests aren't specified in
1309 the POSIX standard.
1310 .SH "ENVIRONMENT VARIABLES"
1312 .IP LANG
1313 Provides a default value for the internationalization variables that
1314 are unset or null.
1316 .IP LC_ALL
1317 If set to a non-empty string value, override the values of all the
1318 other internationalization variables.
1320 .IP LC_COLLATE
1321 The POSIX standard specifies that this variable affects the pattern
1322 matching to be used for the `\-name' option.   GNU find uses the 
1323 .BR fnmatch (3) 
1324 library function, and so support for `LC_COLLATE' depends on the
1325 system library.    
1328 POSIX also specifies that the `LC_COLLATE' environment 
1329 variable affects the interpretation of the user's response to the 
1330 query issued by `\-ok', but this is not the case for GNU find.
1332 .IP LC_CTYPE 
1333 This variable affects the treatment of character classes used with 
1334 the `\-name' test, if the system's 
1335 .BR fnmatch (3) 
1336 library function supports this.   It has no effect on the behaviour 
1337 of the `\-ok' expression.
1339 .IP LC_MESSAGES
1340 Determines the locale to be used for internationalised messages.
1342 .IP NLSPATH
1343 Determines the location of the internationalisation message catalogues.
1345 .IP PATH
1346 Affects the directories which are searched to find the executables 
1347 invoked by `\-exec', `\-execdir', `\-ok' and `\-okdir'.
1349 .IP POSIXLY_CORRECT
1350 Determines the block size used by `\-ls' and `\-fls'.  
1351 If 
1352 .B POSIXLY_CORRECT
1353 is set, blocks are units of 512 bytes.  Otherwise
1354 they are units of 1024 bytes.
1356 .IP TZ
1357 Affects the time zone used for some of the time-related format
1358 directives of \-printf and \-fprintf.
1359 .SH "EXAMPLES"
1361 .B find /tmp \-name core \-type f \-print | xargs /bin/rm \-f
1364 Find files named 
1365 .B core
1366 in or below the directory 
1367 .B /tmp 
1368 and delete them.  Note that this will work incorrectly if there are 
1369 any filenames containing newlines, single or double quotes, or spaces.
1371 .B find /tmp \-name core \-type f \-print0 | xargs \-0 /bin/rm \-f
1374 Find files named 
1375 .B core
1376 in or below the directory 
1377 .B /tmp 
1378 and delete them, processing filenames in such a way that file or
1379 directory names containing single or double quotes, spaces or newlines
1380 are correctly handled.  The
1381 .B \-name 
1382 test comes before the 
1383 .B \-type
1384 test in order to avoid having to call 
1385 .B stat(2) 
1386 on every file.
1390 .B find . \-type f \-exec file \(aq{}\(aq \e\;
1393 Runs `file' on every file in or below the current directory.  Notice
1394 that the braces are enclosed in single quote marks to protect them
1395 from interpretation as shell script punctuation.  The semicolon is
1396 similarly protected by the use of a backslash, though single quotes
1397 could have been used in that case also.
1401 .B find /  \e
1402 .B \e( \-perm \-4000 \-fprintf /root/suid.txt "%#m %u %p\en" \e) , \e
1403 .B \e( \-size +100M \-fprintf /root/big.txt  "%\-10s %p\en" \e)
1406 Traverse the filesystem just once, listing setuid files and
1407 directories into
1408 .B /root/suid.txt
1409 and large files into 
1410 .BR /root/big.txt .
1414 .B find $HOME  \-mtime 0
1417 Search for files in your home directory which have been modified in
1418 the last twenty-four hours.  This command works this way because the
1419 time since each file was last modified is divided by 24 hours and any 
1420 remainder is discarded.  That means that to match 
1421 .B \-mtime 
1422 .BR 0 ,
1423 a file will have to have a modification in the past which is less than
1424 24 hours ago.
1428 .B find /sbin /usr/sbin -executable \e! -readable \-print
1431 Search for files which are executable but not readable.
1435 .B find . \-perm 664
1438 Search for files which have read and write permission for their owner,
1439 and group, but which other users can read but not write to.  Files
1440 which meet these criteria but have other permissions bits set (for
1441 example if someone can execute the file) will not be matched.
1445 .B find . \-perm \-664
1448 Search for files which have read and write permission for their owner
1449 and group, and which other users can read, without regard to the
1450 presence of any extra permission bits (for example the executable
1451 bit).  This will match a file which has mode 0777, for example.
1455 .B find . \-perm /222
1458 Search for files which are writable by somebody (their owner, or
1459 their group, or anybody else).
1463 .B find . \-perm /220
1464 .B find . \-perm /u+w,g+w
1465 .B find . \-perm /u=w,g=w
1468 All three of these commands do the same thing, but the first one uses
1469 the octal representation of the file mode, and the other two use the
1470 symbolic form.  These commands all search for files which are
1471 writable by either their owner or their group.  The files don't have
1472 to be writable by both the owner and group to be matched; either will
1477 .B find . \-perm \-220
1478 .B find . \-perm \-g+w,u+w
1481 Both these commands do the same thing; search for files which are
1482 writable by both their owner and their group.
1486 .B find . \-perm \-444 \-perm /222 ! \-perm /111
1487 .B find . \-perm \-a+r \-perm /a+w ! \-perm /a+x
1490 These two commands both search for files that are readable for
1491 everybody (\-perm \-444 or \-perm \-a+r), have at least on write bit
1492 set (\-perm /222 or \-perm /a+w) but are not executable for anybody (!
1493 \-perm /111 and ! \-perm /a+x respectively)
1497 .B cd /source-dir
1498 .B find . \-name .snapshot \-prune \-o \e( \e! \-name "*~" \-print0 \e)|
1499 .B cpio \-pmd0   /dest-dir
1501 .fi 
1502 This command copies the contents of 
1503 .B /source-dir
1504 to 
1505 .BR /dest-dir ,
1506 but omits files and directories named 
1507 .B .snapshot 
1508 (and anything in them).  It also omits files or directories whose name
1509 ends in
1510 .BR ~ ,
1511 but not their contents.  The construct 
1512 .B \-prune \-o \e( ... \-print0 \e)
1513 is quite common.  The idea here is that the expression before 
1514 .B \-prune 
1515 matches things which are to be pruned.  However, the 
1516 .B \-prune 
1517 action itself returns true, so the following 
1518 .B \-o 
1519 ensures that the right hand side is evaluated only for those
1520 directories which didn't get pruned (the contents of the pruned
1521 directories are not even visited, so their contents are irrelevant).
1522 The expression on the right hand side of the 
1523 .B \-o
1524 is in parentheses only for clarity.  It emphasises that the
1525 .B \-print0 
1526 action takes place only for things that didn't have 
1527 .B \-prune 
1528 applied to them.  Because the default `and' condition between tests
1529 binds more tightly than 
1530 .BR \-o ,
1531 this is the default anyway, but the parentheses help to show
1532 what is going on.
1534 .SH EXIT STATUS
1536 .B find
1537 exits with status 0 if all files are processed successfully, greater
1538 than 0 if errors occur.   This is deliberately a very broad
1539 description, but if the return value is non-zero, you should not rely
1540 on the correctness of the results of 
1541 .BR find .
1543 .SH "SEE ALSO"
1544 \fBlocate\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1), \fBxargs\fP(1),
1545 \fBchmod\fP(1), \fBfnmatch\fP(3), \fBregex\fP(7), \fBstat\fP(2),
1546 \fBlstat\fP(2), \fBls\fP(1), \fBprintf\fP(3), \fBstrftime\fP(3),
1547 \fBctime\fP(3), \fBFinding Files\fP (on-line in Info, or printed).
1548 .SH "HISTORY"
1549 As of findutils-4.2.2, shell metacharacters (`*', `?' or `[]' for
1550 example) used in filename patterns will match a leading `.', because
1551 IEEE POSIX interpretation 126 requires this.
1553 The syntax 
1554 \.B \-perm +MODE 
1555 was deprecated in findutils-4.2.21, in favour of
1556 \.B \-perm 
1557 .BR /MODE .
1558 As of findutils-4.3.3, 
1559 .B \-perm /000
1560 now matches all files instead of none.  
1562 Nanosecond-resolution
1563 timestamps were implemented in findutils-4.3.3.
1565 l l l .
1566 Feature Added in        Also occurs in 
1567 \-newerXY       4.3.3   BSD
1568 \-D     4.3.1
1569 \-O     4.3.1
1570 \-readable      4.3.0
1571 \-writable      4.3.0
1572 \-executable    4.3.0
1573 \-regextype     4.2.24
1574 \-exec ... +    4.2.12  POSIX
1575 \-execdir       4.2.12  BSD
1576 \-okdir 4.2.12
1577 \-samefile      4.2.11
1578 \-H     4.2.5   POSIX
1579 \-L     4.2.5   POSIX
1580 \-P     4.2.5   BSD
1581 \-delete        4.2.3   
1582 \-quit  4.2.3
1583 \-d     4.2.3   BSD
1584 \-wholename     4.2.0
1585 \-iwholename    4.2.0
1586 \-ignore_readdir_race   4.2.0
1587 \-fls   4.0
1588 \-ilname        3.8
1589 \-iname 3.8
1590 \-ipath 3.8
1591 \-iregex        3.8
1593 .SH "NON-BUGS"
1595 .B $ find . \-name *.c \-print
1596 find: paths must precede expression
1597 Usage: find [\-H] [\-L] [\-P] [\-Olevel] [\-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
1600 This happens because 
1601 .I *.c 
1602 has been expanded by the shell
1603 resulting in 
1604 .B find
1605 actually receiving a command line like this:
1608 .B find . \-name bigram.c code.c frcode.c locate.c \-print
1611 That command is of course not going to work.  Instead of doing things
1612 this way, you should enclose the pattern in quotes or escape the wildcard:
1614 .B $ find . \-name \e*.c \-print
1617 .SH "BUGS"
1619 There are security problems inherent in the behaviour that the POSIX
1620 standard specifies for
1621 .BR find ,
1622 which therefore cannot be fixed.  For example, the \-exec action is
1623 inherently insecure, and \-execdir should be used instead.  
1624 Please see \fBFinding Files\fP for more information. 
1626 The environment variable 
1627 .B  LC_COLLATE
1628 has no effect on the 
1629 .B \-ok 
1630 action.
1631 .P 
1632 The best way to report a bug is to use the form at
1633 http://savannah.gnu.org/bugs/?group=findutils.  
1634 The reason for this is that you will then be able to track progress in
1635 fixing the problem.   Other comments about \fBfind\fP(1) and about
1636 the findutils package in general can be sent to the 
1637 .I bug\-findutils
1638 mailing list.  To join the list, send email to 
1639 .IR bug\-findutils\-request@gnu.org .