Updated Romanian, Slovak and Estonian translations from Translation Project
[findutils.git] / find / find.1
blobccd8e7c9245247a1aacfc61e30611881dc253eee
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] [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 `!'.  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 \-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).
123 .SH EXPRESSIONS
124 The expression is made up of options (which affect overall operation
125 rather than the processing of a specific file, and always return
126 true), tests (which return a true or false value), and actions (which
127 have side effects and return a true or false value), all separated by
128 operators.  \-and is assumed where the operator is omitted.  
130 If the expression contains no actions other than \-prune, \-print is
131 performed on all files for which the expression is true.
133 .SS OPTIONS
135 All options always return true.  Except for \-follow and \-daystart,
136 they always take effect, rather than being processed only when their
137 place in the expression is reached.  Therefore, for clarity, it is
138 best to place them at the beginning of the expression.  A warning is
139 issued if you don't do this.
140 .IP \-daystart
141 Measure times (for \-amin, \-atime, \-cmin, \-ctime, \-mmin, and \-mtime)
142 from the beginning of today rather than from 24 hours ago.  This
143 option only affects tests which appear later on the command line.
144 .IP \-depth
145 Process each directory's contents before the directory itself.
146 .IP \-d
147 A synonym for \-depth, for compatibility with FreeBSD, NetBSD, MacOS X and OpenBSD.
148 .IP \-follow
149 Deprecated; use the \-L option instead.  Dereference symbolic links.
150 Implies \-noleaf.  Unless the \-H or \-L option has been specified,
151 the position of the \-follow option changes the behaviour of the
152 \-newer predicate; any files listed as the argument of \-newer will be
153 dereferenced if they are symbolic links.  The same consideration
154 applies to \-anewer and \-cnewer.  Similarly, the \-type predicate
155 will always match against the type of the file that a symbolic link
156 points to rather than the link itself.  Using \-follow causes the
157 \-lname and \-ilname predicates always to return false.
158 .IP "\-help, \-\-help"
159 Print a summary of the command-line usage of
160 .B find
161 and exit.
162 .IP \-ignore_readdir_race
163 Normally, \fBfind\fR will emit an error message when it fails to stat a file.
164 If you give this option and a file is deleted between the time \fBfind\fR 
165 reads the name of the file from the directory and the time it tries to stat 
166 the file, no error message will be issued.    This also applies to files
167 or directories whose names are given on the command line.  This option takes
168 effect at the time the command line is read, which means that you cannot search
169 one part of the filesystem with this option on and part of it with this option
170 off (if you need to do that, you will need to issue two \fBfind\fR commands
171 instead, one with the option and one without it).
172 .IP "\-maxdepth \fIlevels\fR"
173 Descend at most \fIlevels\fR (a non-negative integer) levels of
174 directories below the command line arguments.  `\-maxdepth 0' means
175 only apply the tests and actions to the command line arguments.
176 .IP "\-mindepth \fIlevels\fR"
177 Do not apply any tests or actions at levels less than \fIlevels\fR (a
178 non-negative integer).  `\-mindepth 1' means process all files except
179 the command line arguments.
180 .IP \-mount
181 Don't descend directories on other filesystems.  An alternate name for
182 \-xdev, for compatibility with some other versions of
183 .BR find .
184 .IP \-noignore_readdir_race
185 Turns off the effect of \-ignore_readdir_race. 
186 .IP "\-noleaf"
187 Do not optimize by assuming that directories contain 2 fewer
188 subdirectories than their hard link count.  This option is needed when
189 searching filesystems that do not follow the Unix directory-link
190 convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount
191 points.  Each directory on a normal Unix filesystem has at least 2
192 hard links: its name and its `.'  entry.  Additionally, its
193 subdirectories (if any) each have a `..'  entry linked to that
194 directory.  When
195 .B find
196 is examining a directory, after it has statted 2 fewer subdirectories
197 than the directory's link count, it knows that the rest of the entries
198 in the directory are non-directories (`leaf' files in the directory
199 tree).  If only the files' names need to be examined, there is no need
200 to stat them; this gives a significant increase in search speed.
201 .IP "\-regextype \fItype\fR"
202 Changes the regular expression syntax understood by 
203 .B \-regex
204 and 
205 .B -iregex
206 tests which occur later on the command line.  Currently-implemented
207 types are emacs, posix-awk, posix-basic (this is the default),
208 posix-egrep and posix-extended.
210 .IP "\-version, \-\-version"
211 Print the \fBfind\fR version number and exit.
212 .IP "\-warn, \-nowarn"
213 Turn warning messages on or off.  These warnings apply only to the
214 command line usage, not to any conditions that 
215 .B find 
216 might encounter when it searches directories.  The default behaviour
217 corresponds to \-warn if standard input is a tty, and to \-nowarn
218 otherwise.
219 .IP \-xdev
220 Don't descend directories on other filesystems.
222 .SS TESTS
224 Numeric arguments can be specified as
225 .IP \fI+n\fP
226 for greater than
227 .IR n ,
228 .IP \fI\-n\fP
229 for less than
230 .IR n ,
231 .IP \fIn\fP
232 for exactly
233 .IR n .
234 .IP "\-amin \fIn\fR"
235 File was last accessed \fIn\fR minutes ago.
236 .IP "\-anewer \fIfile\fR"
237 File was last accessed more recently than \fIfile\fR was modified.  If
238 \fIfile\fR is a symbolic link and the \-H option or the \-L option is
239 in effect, the access time of the file it points to is always
240 used.
241 .IP "\-atime \fIn\fR"
242 File was last accessed \fIn\fR*24 hours ago.  
243 When find figures out how many 24-hour periods ago the file 
244 was last accessed, any fractional part is ignored, so to match 
245 .B \-atime 
246 .BR +1 ,
247 a file has to have been accessed at least 
248 .I two
249 days ago.
250 .IP "\-cmin \fIn\fR"
251 File's status was last changed \fIn\fR minutes ago.
252 .IP "\-cnewer \fIfile\fR"
253 File's status was last changed more recently than \fIfile\fR was
254 modified.  If \fIfile\fR is a symbolic link and the \-H option or the
255 \-L option is in effect, the status-change time of the file it points
256 to is always used.
258 .IP "\-ctime \fIn\fR"
259 File's status was last changed \fIn\fR*24 hours ago.
260 See the comments for 
261 .B \-atime 
262 to understand how rounding affects the interpretation of file status
263 change times.
264 .IP \-empty
265 File is empty and is either a regular file or a directory.
266 .IP \-false
267 Always false.
268 .IP "\-fstype \fItype\fR"
269 File is on a filesystem of type \fItype\fR.  The valid filesystem
270 types vary among different versions of Unix; an incomplete list of
271 filesystem types that are accepted on some version of Unix or another
272 is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K.  You can use \-printf
273 with the %F directive to see the types of your filesystems.
274 .IP "\-gid \fIn\fR"
275 File's numeric group ID is \fIn\fR.
276 .IP "\-group \fIgname\fR"
277 File belongs to group \fIgname\fR (numeric group ID allowed).
278 .IP "\-ilname \fIpattern\fR"
279 Like \-lname, but the match is case insensitive.
280 If the \-L option or the \-follow option is in effect, this test 
281 returns false unless the symbolic link is broken.
282 .IP "\-iname \fIpattern\fR"
283 Like \-name, but the match is case insensitive.  For example, the
284 patterns `fo*' and `F??' match the file names `Foo', `FOO', `foo',
285 `fOo', etc.   In these patterns, unlike filename expansion by the
286 shell, an initial '.' can be matched by '*'.  That is, 
287 .B find \-name *bar 
288 will match the file `.foobar'.
290 .IP "\-inum \fIn\fR"
291 File has inode number \fIn\fR.  It is normally easier to use the 
292 .B \-samefile
293 test instead.
294 .IP "\-ipath \fIpattern\fR"
295 Behaves in the same way as \-iwholename.  This option is deprecated,
296 so please do not use it.
297 .IP "\-iregex \fIpattern\fR"
298 Like \-regex, but the match is case insensitive.
299 .IP "\-iwholename \fIpattern\fR"
300 Like \-wholename, but the match is case insensitive.
301 .IP "\-links \fIn\fR"
302 File has \fIn\fR links.
303 .IP "\-lname \fIpattern\fR"
304 File is a symbolic link whose contents match shell pattern
305 \fIpattern\fR.  The metacharacters do not treat `/' or `.' specially.
306 If the \-L option or the \-follow option is in effect, this test 
307 returns false unless the symbolic link is broken.
308 .IP "\-mmin \fIn\fR"
309 File's data was last modified \fIn\fR minutes ago.
310 .IP "\-mtime \fIn\fR"
311 File's data was last modified \fIn\fR*24 hours ago.
312 See the comments for 
313 .B \-atime 
314 to understand how rounding affects the interpretation of file
315 modification times.
316 .IP "\-name \fIpattern\fR"
317 Base of file name (the path with the leading directories removed)
318 matches shell pattern \fIpattern\fR.  The metacharacters (`*', `?',
319 and `[]') match a `.' at the start of the base name (this is a change
320 in findutils-4.2.2; see section STANDARDS CONFORMANCE below).  To ignore a
321 directory and the files under it, use \-prune; see an example in the
322 description of \-wholename.  Braces are not recognised as being
323 special, despite the fact that some shells including Bash imbue braces
324 with a special meaning in shell patterns.  The filename matching is
325 performed with the use of the
326 .BR fnmatch (3) 
327 library function.   Don't forget to enclose the pattern in quotes 
328 in order to protect it from expansion by the shell.
330 .IP "\-newer \fIfile\fR"
331 File was modified more recently than \fIfile\fR.  If \fIfile\fR is a
332 symbolic link and the \-H option or the \-L option is in effect, the
333 modification time of the file it points to is always used.
334 .IP \-nouser
335 No user corresponds to file's numeric user ID.
336 .IP \-nogroup
337 No group corresponds to file's numeric group ID.
338 .IP "\-path \fIpattern\fR"
339 See \-wholename.   The predicate \-path is also supported by HP-UX 
340 .BR find .
341 .IP "\-perm \fImode\fR"
342 File's permission bits are exactly \fImode\fR (octal or symbolic).
343 Since an exact match is required, if you want to use this form for
344 symbolic modes, you may have to specify a rather complex mode string.
345 For example '\-perm g=w' will only match files which have mode 0020
346 (that is, ones for which group write permission is the only permission
347 set).  It is more likely that you will want to use the '+' or '-'
348 forms, for example '\-perm -g=w', which matches any file with group
349 write permission.  See the
350 .B EXAMPLES 
351 section for some illustrative examples.
352 .IP "\-perm \-\fImode\fR"
353 All of the permission bits \fImode\fR are set for the file.
354 Symbolic modes are accepted in this form, and this is usually the way
355 in which would want to use them.  You must specify 'u', 'g' or 'o' if
356 you use a symbolic mode.   See the 
357 .B EXAMPLES 
358 section for some illustrative examples.
359 .IP "\-perm +\fImode\fR"
360 Any of the permission bits \fImode\fR are set for the file.  Symbolic
361 modes are accepted in this form.  You must specify 'u', 'g' or 'o' if
362 you use a symbolic mode.  See the
363 .B EXAMPLES 
364 section for some illustrative examples.
365 .IP "\-regex \fIpattern\fR"
366 File name matches regular expression \fIpattern\fR.  This is a match
367 on the whole path, not a search.  For example, to match a file named
368 `./fubar3', you can use the regular expression `.*bar.' or `.*b.*3',
369 but not `f.*r3'.  The regular expressions understood by 
370 .B find 
371 are by default POSIX Basic Regular Expressions, but this can be
372 changed with the 
373 .B \-regextype 
374 option.
375 .IP "\-samefile \fIname\fR"
376 File refers to the same inode as \fIname\fR.   When -L is in effect,
377 this can include symbolic links.
378 .IP "\-size \fIn\fR[cwbkMG]"
379 File uses \fIn\fP units of space.  The following suffixes 
380 can be used:
382 .IP `b' 
383 for 512-byte blocks (this is the default if no suffix is used)
384 .IP `c' 
385 for bytes
386 .IP `w' 
387 for two-byte words
388 .IP `k' 
389 for Kilobytes (units of 1024 bytes)
390 .IP `M' 
391 for Megabytes (units of 1048576 bytes)
392 .IP `G' 
393 for Gigabytes (units of 1073741824 bytes)
396 The size does not count indirect blocks, but it does count blocks in
397 sparse files that are not actually allocated.  Bear in mind that the
398 `%k' and `%b' format specifiers of \-printf handle sparse files
399 differently.  The `b' suffix always denotes 512-byte blocks and never
400 1 Kilobyte blocks, which is different to the behaviour of \-ls.
402 .IP \-true
403 Always true.
404 .IP "\-type \fIc\fR"
405 File is of type \fIc\fR:
407 .IP b
408 block (buffered) special
409 .IP c
410 character (unbuffered) special
411 .IP d
412 directory
413 .IP p
414 named pipe (FIFO)
415 .IP f
416 regular file
417 .IP l
418 symbolic link (never true if the \-L option or the \-follow option is
419 in effect, unless the symbolic link is broken).
420 .IP s
421 socket
422 .IP D
423 door (Solaris)
425 .IP "\-uid \fIn\fR"
426 File's numeric user ID is \fIn\fR.
427 .IP "\-used \fIn\fR"
428 File was last accessed \fIn\fR days after its status was last changed.
429 .IP "\-user \fIuname\fR"
430 File is owned by user \fIuname\fR (numeric user ID allowed).
431 .IP "\-wholename \fIpattern\fR"
432 File name matches shell pattern \fIpattern\fR.  The metacharacters do
433 not treat `/' or `.' specially; so, for example,
435 .in +1i
436 find . \-wholename './sr*sc'
438 .in -1i
439 will print an entry for a directory called './src/misc' (if one
440 exists).  To ignore a whole directory tree, use \-prune rather than
441 checking every file in the tree.  For example, to skip the
442 directory `src/emacs' and all files and directories under it, and
443 print the names of the other files found, do something like this:
445 .in +1i
446 find . \-wholename './src/emacs' \-prune \-o \-print
448 .in -1i
449 .IP "\-xtype \fIc\fR"
450 The same as \-type unless the file is a symbolic link.  For symbolic
451 links: if the \-H or \-P option was specified, true if the file is a
452 link to a file of type \fIc\fR; if the \-L option has been given, true
453 if \fIc\fR is `l'.  In other words, for symbolic links, \-xtype checks
454 the type of the file that \-type does not check.
456 .SS ACTIONS
457 .IP "\-delete\fR"
458 Delete files; true if removal succeeded.  If the removal failed, an
459 error message is issued.  Use of this action automatically turns on
460 the '\-depth' option.
462 .IP "\-exec \fIcommand\fR ;"
463 Execute \fIcommand\fR; true if 0 status is returned.  All following
464 arguments to
465 .B find
466 are taken to be arguments to the command until an argument consisting
467 of `;' is encountered.  The string `{}' is replaced by the current
468 file name being processed everywhere it occurs in the arguments to the
469 command, not just in arguments where it is alone, as in some versions
471 .BR find .
472 Both of these constructions might need to be escaped (with a `\e') or
473 quoted to protect them from expansion by the shell.  See the
474 .B EXAMPLES
475 section for examples of the use of the `\-exec' option.  The specified
476 command is run once for each matched file.
477 The command is executed in the starting directory.   There are
478 unavoidable security problems surrounding use of the -exec option;
479 you should use the -execdir option instead.  
481 .IP "\-exec \fIcommand\fR {} +"
482 This variant of the -exec option runs the specified command on the
483 selected files, but the command line is built by appending each
484 selected file name at the end; the total number of invocations of the
485 command will be much less than the number of matched files.  The
486 command line is built in much the same way that
487 .B xargs
488 builds its command lines.  Only one instance of '{}' is allowed within
489 the command.  The command is executed in the starting directory.
491 .IP "\-execdir \fIcommand\fR ;"
492 .IP "\-execdir \fIcommand\fR {} +"
493 Like -exec, but the specified command is run from the subdirectory
494 containing the matched file, which is not normally the directory in
495 which you started 
496 .BR find .
497 This a much more secure method for invoking commands, as it avoids
498 race conditions during resolution of the paths to the matched files.
499 As with the -exec option, the '+' form of -execdir will build a
500 command line to process more than one matched file, but any given
501 invocation of
502 .I command 
503 will only list files that exist in the same subdirectory.  If you use
504 this option, you must ensure that your 
505 .B $PATH
506 environment variable does not reference the current directory;
507 otherwise, an attacker can run any commands they like by leaving an
508 appropriately-named file in a directory in which you will run
509 \-execdir.
511 .IP "\-fls \fIfile\fR"
512 True; like \-ls but write to \fIfile\fR like \-fprint.
513 The output file is always created, even if the predicate is never
514 matched.  
515 See the
516 .B UNUSUAL FILENAMES
517 section for information about how unusual characters in filenames are handled.
519 .IP "\-fprint \fIfile\fR"
520 True; print the full file name into file \fIfile\fR.  If \fIfile\fR
521 does not exist when \fBfind\fR is run, it is created; if it does
522 exist, it is truncated.  The file names ``/dev/stdout'' and
523 ``/dev/stderr'' are handled specially; they refer to the standard
524 output and standard error output, respectively.
525 The output file is always created, even if the predicate is never matched.
526 See the
527 .B UNUSUAL FILENAMES
528 section for information about how unusual characters in filenames are handled.
529 .IP "\-fprint0 \fIfile\fR"
530 True; like \-print0 but write to \fIfile\fR like \-fprint.
531 The output file is always created, even if the predicate is never matched.
532 See the
533 .B UNUSUAL FILENAMES
534 section for information about how unusual characters in filenames are handled.
535 .IP "\-fprintf \fIfile\fR \fIformat\fR"
536 True; like \-printf but write to \fIfile\fR like \-fprint.
537 The output file is always created, even if the predicate is never matched.
538 See the
539 .B UNUSUAL FILENAMES
540 section for information about how unusual characters in filenames are handled.
541 .IP "\-ok \fIcommand\fR ;"
542 Like \-exec but ask the user first (on the standard input); if the
543 response does not start with `y' or `Y', do not run the command, and
544 return false.  If the command is run, its standard input is redirected
545 from
546 .BR /dev/null .
548 .IP \-print
549 True; print the full file name on the standard output, followed by a
550 newline.   If you are piping the output of 
551 .B find 
552 into another program and there is the faintest possibility that the files 
553 which you are searching for might contain a newline, then you should 
554 seriously consider using the `\-print0' option instead of `\-print'.
555 See the
556 .B UNUSUAL FILENAMES
557 section for information about how unusual characters in filenames are handled.
558 .IP "\-okdir \fIcommand\fR ;"
559 Like \-execdir but ask the user first (on the standard input); if the
560 response does not start with `y' or `Y', do not run the command, and
561 return false.  If the command is run, its standard input is redirected
562 from
563 .BR /dev/null .
564 .IP \-print0
565 True; print the full file name on the standard output, followed by a
566 null character (instead of the newline character that `\-print' uses).
567 This allows file names that contain newlines or other types of white
568 space to be correctly interpreted by programs that process the
569 \fBfind\fR output.  This option corresponds to the `\-0' option of
570 .BR xargs .
571 .IP "\-printf \fIformat\fR"
572 True; print \fIformat\fR on the standard output, interpreting `\e'
573 escapes and `%' directives.  Field widths and precisions can be
574 specified as with the `printf' C function.  Please note that many of
575 the fields are printed as %s rather than %d, and this may mean that
576 flags don't work as you might expect.  This also means that the `\-'
577 flag does work (it forces fields to be left-aligned).  Unlike \-print,
578 \-printf does not add a newline at the end of the string.  The escapes
579 and directives are:
581 .IP \ea
582 Alarm bell.
583 .IP \eb
584 Backspace.
585 .IP \ec
586 Stop printing from this format immediately and flush the output.
587 .IP \ef
588 Form feed.
589 .IP \en
590 Newline.
591 .IP \er
592 Carriage return.
593 .IP \et
594 Horizontal tab.
595 .IP \ev
596 Vertical tab.
597 .IP \e\0
598 ASCII NUL.
599 .IP \e\e
600 A literal backslash (`\e').
601 .IP \eNNN
602 The character whose ASCII code is NNN (octal).
604 A `\e' character followed by any other character is treated as an
605 ordinary character, so they both are printed.
606 .IP %%
607 A literal percent sign.
608 .IP %a
609 File's last access time in the format returned by the C `ctime' function.
610 .IP %A\fIk\fP
611 File's last access time in the format specified by \fIk\fR, which is
612 either `@' or a directive for the C `strftime' function.  The possible
613 values for \fIk\fR are listed below; some of them might not be
614 available on all systems, due to differences in `strftime' between
615 systems.  
617 .IP @
618 seconds since Jan. 1, 1970, 00:00 GMT.
620 Time fields:
621 .IP H
622 hour (00..23)
623 .IP I
624 hour (01..12)
625 .IP k
626 hour ( 0..23)
627 .IP l
628 hour ( 1..12)
629 .IP M
630 minute (00..59)
631 .IP p
632 locale's AM or PM
633 .IP r
634 time, 12-hour (hh:mm:ss [AP]M)
635 .IP S
636 second (00..61)
637 .IP T
638 time, 24-hour (hh:mm:ss)
639 .IP +
640 Date and time, separated by '+', for example `2004\-04\-28+22:22:05'.
641 The time is given in the current timezone (which may be affected by
642 setting the TZ environment variable).  This is a GNU extension.
643 .IP X
644 locale's time representation (H:M:S)
645 .IP Z
646 time zone (e.g., EDT), or nothing if no time zone is determinable
648 Date fields:
649 .IP a
650 locale's abbreviated weekday name (Sun..Sat)
651 .IP A
652 locale's full weekday name, variable length (Sunday..Saturday)
653 .IP b
654 locale's abbreviated month name (Jan..Dec)
655 .IP B
656 locale's full month name, variable length (January..December)
657 .IP c
658 locale's date and time (Sat Nov 04 12:02:33 EST 1989)
659 .IP d
660 day of month (01..31)
661 .IP D
662 date (mm/dd/yy)
663 .IP h
664 same as b
665 .IP j
666 day of year (001..366)
667 .IP m
668 month (01..12)
669 .IP U
670 week number of year with Sunday as first day of week (00..53)
671 .IP w
672 day of week (0..6)
673 .IP W
674 week number of year with Monday as first day of week (00..53)
675 .IP x
676 locale's date representation (mm/dd/yy)
677 .IP y
678 last two digits of year (00..99)
679 .IP Y
680 year (1970...)
682 .IP %b
683 The amount of disk space used for this file in 512-byte blocks. Since disk
684 space is allocated in multiples of the filesystem block size this is usually
685 greater than %s/1024, but it can also be smaller if the file is a sparse file.
686 .IP %c
687 File's last status change time in the format returned by the C `ctime'
688 function.
689 .IP %C\fIk\fP
690 File's last status change time in the format specified by \fIk\fR,
691 which is the same as for %A.
692 .IP %d
693 File's depth in the directory tree; 0 means the file is a command line
694 argument.
695 .IP %D
696 The device number on which the file exists (the st_dev field of struct
697 stat), in decimal.
698 .IP %f
699 File's name with any leading directories removed (only the last element).
700 .IP %F
701 Type of the filesystem the file is on; this value can be used for
702 \-fstype.
703 .IP %g
704 File's group name, or numeric group ID if the group has no name.
705 .IP %G
706 File's numeric group ID.
707 .IP %h
708 Leading directories of file's name (all but the last element).
709 If the file name contains no slashes (since it is in the current 
710 directory) the %h specifier expands to ".".
711 .IP %H
712 Command line argument under which file was found.
713 .IP %i
714 File's inode number (in decimal).
715 .IP %k
716 The amount of disk space used for this file in 1K blocks. Since disk space is
717 allocated in multiples of the filesystem block size this is usually greater
718 than %s/1024, but it can also be smaller if the file is a sparse file.
719 .IP %l
720 Object of symbolic link (empty string if file is not a symbolic link).
721 .IP %m
722 File's permission bits (in octal).  This option uses the 'traditional'
723 numbers which most Unix implementations use, but if your particular 
724 implementation uses an unusual ordering of octal permissions bits, you
725 will see a difference between the actual value of the file's mode and
726 the output of %m.   Normally you will want to have a leading
727 zero on this number, and to do this, you should use the 
728 .B #
729 flag (as in, for example, '%#m').
730 .IP %n
731 Number of hard links to file.
732 .IP %p
733 File's name.
734 .IP %P
735 File's name with the name of the command line argument under which
736 it was found removed.
737 .IP %s
738 File's size in bytes.
739 .IP %t
740 File's last modification time in the format returned by the C `ctime'
741 function.
742 .IP %T\fIk\fP
743 File's last modification time in the format specified by \fIk\fR, 
744 which is the same as for %A.
745 .IP %u
746 File's user name, or numeric user ID if the user has no name.
747 .IP %U
748 File's numeric user ID.
749 .IP %y
750 File's type (like in ls \-l), U=unknown type (shouldn't happen)
751 .IP %Y
752 File's type (like %y), plus follow symlinks: L=loop, N=nonexistent
754 A `%' character followed by any other character is discarded (but the
755 other character is printed).
757 The %m and %d directives support the 
758 .B #
760 .B 0 
761 and 
762 .B + 
763 flags, but the other directives do not, even if they
764 print numbers.  Numeric directives that do not support these flags
765 include 
766 .BR G , 
767 .BR U , 
768 .BR b , 
769 .BR D , 
770 .B  k 
771 and 
772 .BR n .
773 The `\-' format flag is supported and changes the alignment of a field
774 from right-justified (which is the default) to left-justified.
776 See the
777 .B UNUSUAL FILENAMES
778 section for information about how unusual characters in filenames are handled.
782 .IP \-prune
783 If \-depth is not given, true; if the file is a directory, do not descend
784 into it.
786 If \-depth is given, false; no effect.
788 .IP "\-quit"
789 Exit immediately.  No child processes will be left running, but no more
790 paths specified on the command line will be processed.  For example,
791 .B find /tmp/foo /tmp/bar \-print \-quit
792 will print only
793 .BR /tmp/foo .
794 Any command lines which have been built up with
795 .B \-execdir ... {} +
796 will be invoked before 
797 .B find
798 exits.   The exit status may or may not be zero, depending on whether
799 an error has already occurred.  
801 .IP \-ls
802 True; list current file in `ls \-dils' format on standard output.
803 The block counts are of 1K blocks, unless the environment variable
804 POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
805 See the
806 .B UNUSUAL FILENAMES
807 section for information about how unusual characters in filenames are handled.
810 .SS UNUSUAL FILENAMES
811 Many of the actions of 
812 .B find
813 result in the printing of data which is under the control of other
814 users.  This includes file names, sizes, modification times and so
815 forth.  File names are a potential problem since they can contain any
816 character except '\\0' and '/'.  Unusual characters in file names can
817 do unexpected and often undesirable things to your terminal (for
818 example, changing the settings of your function keys on some
819 terminals).  Unusual characters are handled differently by various
820 actions, as described below.
821 .IP "\-print0, \-fprint0\"
822 Always print the exact filename, unchanged, even if the output is
823 going to a terminal.
824 .IP "\-ls, \-fls"
825 Unusual characters are always escaped.  White space, backslash, and
826 double quote characters are printed using C-style escaping (for
827 example '\\f', '\\"').  Other unusual characters are printed using an
828 octal escape.  Other printable characters (for \-ls and -fls these are
829 the characters between octal 041 and 0176) are printed as-is.
830 .IP "\-printf, \-fprintf"
831 If the output is not going to a terminal, it is printed as-is.
832 Otherwise, the result depends on which directive is in use.  The
833 directives %D, %F, %g, %G, %H, %Y, and %y expand to values which are
834 not under control of files' ownwers, and so are printed as-is.  The
835 directives %a, %b, %c, %d, %i, %k, %m, %M, %n, %s, %t, %u and %U have
836 values which are under the control of files' ownwers but which cannot
837 be used to send arbitrary data to the terminal, and so these are
838 printed as-is.  The directives %f, %h, %l, %p and %P are quoted.  This
839 quoting is performed in the same way as for GNU
840 .BR ls .   
841 This is not the same quoting mechanism as the one used for  \-ls and
842 \-fls.   If you are able to decide what format to use for the output 
843 of 
844 .B find
845 then it is normally better to use '\\0' as a terminator
846 than to use newline, as file names can contain white space and newline
847 characters.
848 .IP "\-print, \-fprint"
849 Quoting is handled in the same way as for \-printf and \-fprintf.
850 If you are using 
851 .B find
852 in a script or in a situation where the matched files might have
853 arbitrary names, you should consider using \-print0 instead of
854 \-print.
856 The \-ok and \-okdir actions print the current filename as-is.  This
857 may change in a future release.
858 .SS OPERATORS
860 Listed in order of decreasing precedence:
861 .IP "( \fIexpr\fR )"
862 Force precedence.
863 .IP "! \fIexpr\fR"
864 True if \fIexpr\fR is false.
865 .IP "\-not \fIexpr\fR"
866 Same as ! \fIexpr\fR, but not POSIX compliant.
867 .IP "\fIexpr1 expr2\fR"
868 Two expressions in a row are taken to be joined with an 
869 implied "and"; \fIexpr2\fR is not evaluated if \fIexpr1\fR is false.
870 .IP "\fIexpr1\fR \-a \fIexpr2\fR"
871 Same as \fIexpr1 expr2\fR.
872 .IP "\fIexpr1\fR \-and \fIexpr2\fR"
873 Same as \fIexpr1 expr2\fR, but not POSIX compliant.
874 .IP "\fIexpr1\fR \-o \fIexpr2\fR"
875 Or; \fIexpr2\fR is not evaluated if \fIexpr1\fR is true.
876 .IP "\fIexpr1\fR \-or \fIexpr2\fR"
877 Same as \fIexpr1\fR \-o \fIexpr2\fR, but not POSIX compliant.
878 .IP "\fIexpr1\fR , \fIexpr2\fR"
879 List; both \fIexpr1\fR and \fIexpr2\fR are always evaluated.
880 The value of \fIexpr1\fR is discarded; the value of the list is the
881 value of \fIexpr2\fR.   
882 The comma operator can be useful for searching for several
883 different types of thing, but traversing the filesystem hierarchy only
884 once.   The 
885 .B \-fprintf  
886 action can be used to list the various matched items into several
887 different output files.
890 .SH "STANDARDS CONFORMANCE"
891 The following options are specified in the POSIX standard 
892 (IEEE Std 1003.1, 2003 Edition):
893 .IP "\-H"
894 This option is supported.
895 .IP "\-L"
896 This option is supported.
897 .IP "\-name"
898 This option is supported, but POSIX conformance depends on the 
899 POSIX conformance of the system's 
900 .BR fnmatch (3) 
901 library function.  As of findutils-4.2.2, shell metacharacters
902 ('*'. '?' or '[]' for example) will match a leading '.', because 
903 IEEE PASC interpretation 126 requires this.   This is a change from
904 previous versions of findutils.
905 .IP "\-type"
906 Supported.   POSIX specifies `b', `c', `d', `l', `p', `f' and `s'.
907 GNU find also supports `D', representing a Door, where the OS provides these.
909 .IP "\-ok"
910 Supported.   Interpretation of the response is not locale-dependent
911 (see ENVIRONMENT VARIABLES).
913 .IP "\-newer"
914 Supported.  If the file specified is a symbolic link, it is always
915 dereferenced.  This is a change from previous behaviour, which used to 
916 take the relevant time from the symbolic link; see the HISTORY section
917 below.
919 .IP "Other predicates"
920 The predicates
921 `\-atime',
922 `\-ctime',
923 `\-depth',
924 `\-group',
925 `\-links',
926 `\-mtime',
927 `\-nogroup',
928 `\-nouser',
929 `\-perm',
930 `\-print',
931 `\-prune',
932 `\-size',
933 `\-user' and 
934 `\-xdev',
935 are all supported.
938 The POSIX standard specifies parentheses `(', `)', negation `!' and the
939 `and' and `or' operators (`\-a', `\-o').   
941 All other options, predicates, expressions and so forth are extensions 
942 beyond the POSIX standard.  Many of these extensions are not unique to 
943 GNU find, however.
945 The POSIX standard requires that 
947 The 
948 .B find
949 utility shall detect infinite loops; that is, entering a
950 previously visited directory that is an ancestor of the last file
951 encountered. When it detects an infinite loop, find shall write a
952 diagnostic message to standard error and shall either recover its
953 position in the hierarchy or terminate.
955 The link count of directories which contain entries which are hard
956 links to an ancestor will often be lower than they otherwise should
957 be.  This can mean that GNU find will sometimes optimise away the
958 visiting of a subdirectory which is actually a link to an ancestor.
959 Since 
960 .B find
961 does not actually enter such a subdirectory, it is allowed to avoid
962 emitting a diagnostic message.  Although this behaviour may be
963 somewhat confusing, it is unlikely that anybody actually depends on
964 this behaviour.  If the leaf optimisation has been turned off with
965 .BR -noleaf ,
966 the directory entry will always be examined and the diagnostic message
967 will be issued where it is appropriate.  Symbolic links cannot be used
968 to create filesystem cycles as such, but if the \-L option or the
969 \-follow option is in use, a diagnostic message is issued when 
970 .B find 
971 encounters a loop of symbolic links.  As with loops containing hard
972 links, the leaf optimisation will often mean that 
973 .B find
974 knows that it doesn't need to call 
975 .I stat()
977 .I chdir() 
978 on the symbolic link, so this diagnostic is frequently not necessary.
980 The \-d option is supported for compatibility with various BSD systems,
981 but you should use the POSIX-compliant predicate \-depth instead.
982 .SH "ENVIRONMENT VARIABLES"
983 .IP LANG
984 Provides a default value for the internationalization variables that
985 are unset or null.
986 .IP LC_ALL
987 If set to a non-empty string value, override the values of all the
988 other internationalization variables.
989 .IP LC_COLLATE
990 The POSIX standard specifies that this variable affects the pattern
991 matching to be used for the `\-name' option.   GNU find uses the 
992 .BR fnmatch (3) 
993 library function, and so support for `LC_COLLATE' depends on the
994 system library.    
996 POSIX also specifies that the `LC_COLLATE' environment 
997 variable affects the interpretation of the user's response to the 
998 query issued by `\-ok', but this is not the case for GNU find.
999 .IP LC_CTYPE 
1000 This variable affects the treatment of character classes used with 
1001 the `\-name' option, if the system's 
1002 .BR fnmatch (3) 
1003 library function supports this.   It has no effect on the behaviour 
1004 of the `\-ok' expression.
1005 .IP LC_MESSAGES
1006 Determines the locale to be used for internationalised messages.
1007 .IP NLSPATH
1008 Determines the location of the internationalisation message catalogues.
1009 .IP PATH
1010 Affects the directories which are searched to find the executables 
1011 invoked by `\-exec', `\-execdir', `\-ok' and `\-okdir'.
1012 .IP POSIXLY_CORRECT
1013 Determines the block size used by `-ls'.
1014 .IP TZ
1015 Affects the time zone used for some of the time-related format
1016 directives of -printf and -fprintf.
1017 .SH "EXAMPLES"
1019 .B find /tmp \-name core \-type f \-print | xargs /bin/rm -f
1022 Find files named 
1023 .B core
1024 in or below the directory 
1025 .B /tmp 
1026 and delete them.  Note that this will work incorrectly if there are 
1027 any filenames containing newlines, single or double quotes, or spaces.
1029 .B find /tmp \-name core \-type f \-print0 | xargs \-0 /bin/rm -f
1032 Find files named 
1033 .B core
1034 in or below the directory 
1035 .B /tmp 
1036 and delete them, processing filenames in such a way that file or
1037 directory names containing single or double quotes, spaces or newlines
1038 are correctly handled.  The
1039 .B \-name 
1040 test comes before the 
1041 .B \-type
1042 test in order to avoid having to call 
1043 .B stat(2) 
1044 on every file.
1048 .B find . \-type f \-exec file '{}' \e\;
1051 Runs `file' on every file in or below the current directory.  Notice
1052 that the braces are enclosed in single quote marks to protect them
1053 from interpretation as shell script punctuation.   The semicolon is
1054 similarly protected by the use of a backslash, though ';' could have
1055 been used in that case also.
1059 .B find /  \t\e( \-perm +4000 \-fprintf /root/suid.txt '%#m %u %p\en' \e) , \e
1060 .B       \t\t\e( \-size +100M \-fprintf /root/big.txt  '%\-10s %p\en' \e)
1063 Traverse the filesystem just once, listing setuid files and
1064 directories into
1065 .B /root/suid.txt
1066 and large files into 
1067 .BR /root/big.txt .
1071 .B find $HOME  -mtime 0
1074 Search for files in your home directory which have been modified in
1075 the last twenty-four hours.  This command works this way because the
1076 time since each file was last modified is divided by 24 hours and any 
1077 remainder is discarded.  That means that to match 
1078 .B -mtime 
1079 .BR 0 ,
1080 a file will have to have a modification in the past which is less than
1081 24 hours ago.
1086 .B find . -perm 664
1089 Search for files which have read and write permission for their owner,
1090 and group, but which other users can read but not write to.  Files
1091 which meet these criteria but have other permissions bits set (for
1092 example if someone can execute the file) will not be matched.
1096 .B find . -perm -664
1099 Search for files which have read and write permission for their owner
1100 and group, and which other users can read, without regard to the
1101 presence of any extra permission bits (for example the executable
1102 bit).  This will match a file which has mode 0777, for example.
1106 .B find . -perm +222
1109 Search for files which are writable by somebody (their owner, or
1110 their group, or anybody else).
1114 .B find . -perm +022
1115 .B find . -perm +g+w,o+w
1116 .B find . -perm +g=w,o=w
1119 All three of these commands do the same thing, but the first one uses
1120 the octal representation of the file mode, and the other two use the
1121 symbolic form.  These commands all search for files which are
1122 writable by either their owner or their group.  The files don't have
1123 to be writable by both the owner and group to be matched; either will
1128 .B find . -perm -022
1129 .B find . -perm -g+w,o+w
1132 Both these commands do the same thing; search for files which are
1133 writable by both their owner and their group.
1137 .SH EXIT STATUS
1139 .B find
1140 exits with status 0 if all files are processed successfully, greater
1141 than 0 if errors occur.   This is deliberately a very broad
1142 description, but if the return value is non-zero, you should not rely
1143 on the correctness of the results of 
1144 .BR find .
1146 .SH "SEE ALSO"
1147 \fBlocate\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1), \fBxargs\fP(1),
1148 \fBfnmatch\fP(3), \fBregex\fP(7), \fBstat\fP(2), \fBlstat\fP(2),
1149 \fBls\fP(1), \fBprintf\fP(3), \fBstrftime\fP(3), \fBctime\fP(3),
1150 \fBFinding Files\fP (on-line in Info, or printed), 
1151 .SH "HISTORY"
1152 As of findutils-4.2.2, shell metacharacters ('*'. '?' or '[]' for
1153 example) used in filename patterns will match a leading '.', because
1154 IEEE POSIX interpretation 126 requires this.
1155 .SH "NON-BUGS"
1157 .B $ find . -name *.c -print
1158 find: paths must precede expression
1159 Usage: find [-H] [-L] [-P] [path...] [expression]
1162 This happens because 
1163 .I *.c 
1164 has been expanded by the shell
1165 resulting in 
1166 .B find
1167 actually receiving a command line like this:
1170 .B find . -name bigram.c code.c frcode.c locate.c -print
1173 That command is of course not going to work.  Instead of doing things
1174 this way, you should enclose the pattern in quotes:
1176 .B $ find . -name \'*.c\' -print
1179 .SH "BUGS"
1181 There are security problems inherent in the behaviour that the POSIX
1182 standard specifies for
1183 .BR find ,
1184 which therefore cannot be fixed.  For example, the -exec action is
1185 inherently insecure, and -execdir should be used instead.  
1186 Please see \fBFinding Files\fP for more information. 
1187 .P 
1188 The best way to report a bug is to use the form at
1189 http://savannah.gnu.org/bugs/?group=findutils.  
1190 The reason for this is that you will then be able to track progress in
1191 fixing the problem.   Other comments about \fBfind\fP(1) and about
1192 the findutils package in general can be sent to the 
1193 .I bug\-findutils
1194 mailing list.  To join the list, send email to 
1195 .IR bug\-findutils\-request@gnu.org .