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