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