Escape "-" in SYNOPSIS. Thanks to Bas van Gompel for noticing this
[findutils.git] / doc / find.texi
blob3e0a11ff3172082f7910cde831df0c5d4c3be1f6
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename find.info
4 @settitle Finding Files
5 @c For double-sided printing, uncomment:
6 @c @setchapternewpage odd
7 @c %**end of header
9 @include version.texi
11 @iftex
12 @finalout
13 @end iftex
15 @dircategory Basics
16 @direntry
17 * Finding files: (find).        Operating on files matching certain criteria.
18 @end direntry
20 @ifinfo
22 This file documents the GNU utilities for finding files that match
23 certain criteria and performing various operations on them.
25 Copyright (C) 1994,1996,1998,2000,2001,2003,2004 Free Software Foundation, Inc.
27 Permission is granted to make and distribute verbatim copies of
28 this manual provided the copyright notice and this permission notice
29 are preserved on all copies.
31 @ignore
32 Permission is granted to process this file through TeX and print the
33 results, provided the printed document carries copying permission
34 notice identical to this one except for the removal of this paragraph
35 (this paragraph not being relevant to the printed manual).
37 @end ignore
38 Permission is granted to copy and distribute modified versions of this
39 manual under the conditions for verbatim copying, provided that the entire
40 resulting derived work is distributed under the terms of a permission
41 notice identical to this one.
43 Permission is granted to copy and distribute translations of this manual
44 into another language, under the above conditions for modified versions,
45 except that this permission notice may be stated in a translation approved
46 by the Foundation.
47 @end ifinfo
49 @titlepage
50 @title Finding Files
51 @subtitle Edition @value{EDITION}, for GNU @code{find} version @value{VERSION}
52 @subtitle @value{UPDATED}
53 @author by David MacKenzie
55 @page
56 @vskip 0pt plus 1filll
57 Copyright @copyright{} 1994,1996,1998,2000,2001,2003,2004 Free Software Foundation, Inc.
59 Permission is granted to make and distribute verbatim copies of
60 this manual provided the copyright notice and this permission notice
61 are preserved on all copies.
63 Permission is granted to copy and distribute modified versions of this
64 manual under the conditions for verbatim copying, provided that the entire
65 resulting derived work is distributed under the terms of a permission
66 notice identical to this one.
68 Permission is granted to copy and distribute translations of this manual
69 into another language, under the above conditions for modified versions,
70 except that this permission notice may be stated in a translation approved
71 by the Foundation.
72 @end titlepage
74 @node Top, Introduction, , (dir)
75 @comment  node-name,  next,  previous,  up
77 @ifinfo
78 This file documents the GNU utilities for finding files that match
79 certain criteria and performing various actions on them.
80 This is edition @value{EDITION}, for @code{find} version @value{VERSION}.
81 @end ifinfo
83 @c The master menu, created with texinfo-master-menu, goes here.
85 @menu
86 * Introduction::                Summary of the tasks this manual describes.
87 * Finding Files::               Finding files that match certain criteria.
88 * Actions::                     Doing things to files you have found.
89 * Common Tasks::                Solutions to common real-world problems.
90 * Databases::                   Maintaining file name databases.
91 * File Permissions::            How to control access to files.
92 * Reference::                   Summary of how to invoke the programs.
93 * Security Considerations::     Security issues relating to findutils.
94 * Error Messages::              Explanations of some messages you might see.
95 * Primary Index::               The components of @code{find} expressions.
96 @end menu
98 @node Introduction, Finding Files, Top, Top
99 @chapter Introduction
101 This manual shows how to find files that meet criteria you specify, and
102 how to perform various actions on the files that you find.  The
103 principal programs that you use to perform these tasks are @code{find},
104 @code{locate}, and @code{xargs}.  Some of the examples in this manual
105 use capabilities specific to the GNU versions of those programs.
107 GNU @code{find} was originally written by Eric Decker, with enhancements
108 by David MacKenzie, Jay Plett, and Tim Wood.  GNU @code{xargs} was
109 originally written by Mike Rendell, with enhancements by David
110 MacKenzie.  GNU @code{locate} and its associated utilities were
111 originally written by James Woods, with enhancements by David MacKenzie.
112 The idea for @samp{find -print0} and @samp{xargs -0} came from Dan
113 Bernstein.  The current maintainer of GNU findutils (and this manual) is
114 James Youngman.  Many other people have contributed bug fixes, small
115 improvements, and helpful suggestions.  Thanks!
117 Mail suggestions and bug reports for these programs to
118 @code{bug-findutils@@gnu.org}.  Please include the version
119 number, which you can get by running @samp{find --version}.
121 @menu
122 * Scope::
123 * Overview::
124 * find Expressions::
125 @end menu
127 @node Scope
128 @section Scope
130 For brevity, the word @dfn{file} in this manual means a regular file, a
131 directory, a symbolic link, or any other kind of node that has a
132 directory entry.  A directory entry is also called a @dfn{file name}.  A
133 file name may contain some, all, or none of the directories in a path
134 that leads to the file.  These are all examples of what this manual
135 calls ``file names'':
137 @example
138 parser.c
139 README
140 ./budget/may-94.sc
141 fred/.cshrc
142 /usr/local/include/termcap.h
143 @end example
145 A @dfn{directory tree} is a directory and the files it contains, all of
146 its subdirectories and the files they contain, etc.  It can also be a
147 single non-directory file.
149 These programs enable you to find the files in one or more directory
150 trees that:
152 @itemize @bullet
153 @item
154 have names that contain certain text or match a certain pattern;
155 @item
156 are links to certain files;
157 @item
158 were last used during a certain period of time;
159 @item
160 are within a certain size range;
161 @item
162 are of a certain type (regular file, directory, symbolic link, etc.);
163 @item
164 are owned by a certain user or group;
165 @item
166 have certain access permissions;
167 @item
168 contain text that matches a certain pattern;
169 @item
170 are within a certain depth in the directory tree;
171 @item
172 or some combination of the above.
173 @end itemize
175 Once you have found the files you're looking for (or files that are
176 potentially the ones you're looking for), you can do more to them than
177 simply list their names.  You can get any combination of the files'
178 attributes, or process the files in many ways, either individually or in
179 groups of various sizes.  Actions that you might want to perform on the
180 files you have found include, but are not limited to:
182 @itemize @bullet
183 @item
184 view or edit
185 @item
186 store in an archive
187 @item
188 remove or rename
189 @item
190 change access permissions
191 @item
192 classify into groups
193 @end itemize
195 This manual describes how to perform each of those tasks, and more.
197 @node Overview
198 @section Overview
200 The principal programs used for making lists of files that match given
201 criteria and running commands on them are @code{find}, @code{locate},
202 and @code{xargs}.  An additional command, @code{updatedb}, is used by
203 system administrators to create databases for @code{locate} to use.
205 @code{find} searches for files in a directory hierarchy and prints
206 information about the files it found.  It is run like this:
208 @example
209 find @r{[}@var{file}@dots{}@r{]} @r{[}@var{expression}@r{]}
210 @end example
212 @noindent
213 Here is a typical use of @code{find}.  This example prints the names of
214 all files in the directory tree rooted in @file{/usr/src} whose name
215 ends with @samp{.c} and that are larger than 100 Kilobytes.
216 @example
217 find /usr/src -name '*.c' -size +100k -print
218 @end example
220 @code{locate} searches special file name databases for file names that
221 match patterns.  The system administrator runs the @code{updatedb}
222 program to create the databases.  @code{locate} is run like this:
224 @example
225 locate @r{[}@var{option}@dots{}@r{]} @var{pattern}@dots{}
226 @end example
228 @noindent
229 This example prints the names of all files in the default file name
230 database whose name ends with @samp{Makefile} or @samp{makefile}.  Which
231 file names are stored in the database depends on how the system
232 administrator ran @code{updatedb}.
233 @example
234 locate '*[Mm]akefile'
235 @end example
237 The name @code{xargs}, pronounced EX-args, means ``combine arguments.''
238 @code{xargs} builds and executes command lines by gathering together
239 arguments it reads on the standard input.  Most often, these arguments
240 are lists of file names generated by @code{find}.  @code{xargs} is run
241 like this:
243 @example
244 xargs @r{[}@var{option}@dots{}@r{]} @r{[}@var{command} @r{[}@var{initial-arguments}@r{]}@r{]}
245 @end example
247 @noindent
248 The following command searches the files listed in the file
249 @file{file-list} and prints all of the lines in them that contain the
250 word @samp{typedef}.
251 @example
252 xargs grep typedef < file-list
253 @end example
255 @node find Expressions
256 @section @code{find} Expressions
258 The expression that @code{find} uses to select files consists of one or
259 more @dfn{primaries}, each of which is a separate command line argument
260 to @code{find}.  @code{find} evaluates the expression each time it
261 processes a file.  An expression can contain any of the following types
262 of primaries:
264 @table @dfn
265 @item options
266 affect overall operation rather than the processing of a specific file;
267 @item tests
268 return a true or false value, depending on the file's attributes;
269 @item actions
270 have side effects and return a true or false value; and
271 @item operators
272 connect the other arguments and affect when and whether they are
273 evaluated.
274 @end table
276 You can omit the operator between two primaries; it defaults to
277 @samp{-and}.  @xref{Combining Primaries With Operators}, for ways to
278 connect primaries into more complex expressions.  If the expression
279 contains no actions other than @samp{-prune}, @samp{-print} is performed
280 on all files for which the entire expression is true (@pxref{Print File
281 Name}).
283 Options take effect immediately, rather than being evaluated for each
284 file when their place in the expression is reached.  Therefore, for
285 clarity, it is best to place them at the beginning of the expression.
287 Many of the primaries take arguments, which immediately follow them in
288 the next command line argument to @code{find}.  Some arguments are file
289 names, patterns, or other strings; others are numbers.  Numeric
290 arguments can be specified as
292 @table @code
293 @item +@var{n}
294 for greater than @var{n},
295 @item -@var{n}
296 for less than @var{n},
297 @item @var{n}
298 for exactly @var{n}.
299 @end table
301 @node Finding Files, Actions, Introduction, Top
302 @chapter Finding Files
304 By default, @code{find} prints to the standard output the names of the
305 files that match the given criteria.  @xref{Actions}, for how to get more
306 information about the matching files.
309 @menu
310 * Name::
311 * Links::
312 * Time::
313 * Size::
314 * Type::
315 * Owner::
316 * Permissions::
317 * Contents::
318 * Directories::
319 * Filesystems::
320 * Combining Primaries With Operators::
321 @end menu
323 @node Name
324 @section Name
326 Here are ways to search for files whose name matches a certain pattern.
327 @xref{Shell Pattern Matching}, for a description of the @var{pattern}
328 arguments to these tests.
330 Each of these tests has a case-sensitive version and a case-insensitive
331 version, whose name begins with @samp{i}.  In a case-insensitive
332 comparison, the patterns @samp{fo*} and @samp{F??} match the file names
333 @file{Foo}, @samp{FOO}, @samp{foo}, @samp{fOo}, etc.
335 @menu
336 * Base Name Patterns::
337 * Full Name Patterns::
338 * Fast Full Name Search::
339 * Shell Pattern Matching::      Wildcards used by these programs.
340 @end menu
342 @node Base Name Patterns
343 @subsection Base Name Patterns
345 @deffn Test -name pattern
346 @deffnx Test -iname pattern
347 True if the base of the file name (the path with the leading directories
348 removed) matches shell pattern @var{pattern}.  For @samp{-iname}, the
349 match is case-insensitive.  To ignore a whole directory tree, use
350 @samp{-prune} (@pxref{Directories}).  As an example, to find Texinfo
351 source files in @file{/usr/local/doc}:
353 @example
354 find /usr/local/doc -name '*.texi'
355 @end example
356 @end deffn
358 Patterns for @samp{-name} and @samp{-iname} will match a filename with
359 a leading @samp{.}.  For example the command @samp{find /tmp -name
360 \*bar} will match the file @file{/tmp/.foobar}.
363 @node Full Name Patterns
364 @subsection Full Name Patterns
366 @deffn Test -wholename pattern
367 @deffnx Test -iwholename pattern
368 True if the entire file name, starting with the command line argument
369 under which the file was found, matches shell pattern @var{pattern}.
370 For @samp{-iwholename}, the match is case-insensitive.  To ignore a
371 whole directory tree, use @samp{-prune} rather than checking every
372 file in the tree (@pxref{Directories}).  The ``entire file name'' as
373 used by find starts with the starting-point specified on the command
374 line, and is not converted to an absolute pathname, so for example
375 @code{cd /; find tmp -wholename /tmp} will never match anything.
376 @end deffn
378 @deffn Test -path pattern
379 @deffnx Test -ipath pattern
380 These tests are deprecated, but work as for @samp{-wholename} and @samp{-iwholename},
381 respectively.  The @samp{-ipath} test is a GNU extension, but @samp{-path} is also 
382 provided by HP-UX @code{find}.
383 @end deffn
385 @deffn Test -regex expr
386 @deffnx Test -iregex expr
387 True if the entire file name matches regular expression @var{expr}.
388 This is a match on the whole path, not a search.  For example, to match
389 a file named @file{./fubar3}, you can use the regular expression
390 @samp{.*bar.} or @samp{.*b.*3}, but not @samp{f.*r3}.  @xref{Regexps, ,
391 Syntax of Regular Expressions, emacs, The GNU Emacs Manual}, for a
392 description of the syntax of regular expressions.  For @samp{-iregex},
393 the match is case-insensitive.
394 @end deffn
396 @node Fast Full Name Search
397 @subsection Fast Full Name Search
399 To search for files by name without having to actually scan the
400 directories on the disk (which can be slow), you can use the
401 @code{locate} program.  For each shell pattern you give it,
402 @code{locate} searches one or more databases of file names and displays
403 the file names that contain the pattern.  @xref{Shell Pattern Matching},
404 for details about shell patterns.
406 If a pattern is a plain string---it contains no
407 metacharacters---@code{locate} displays all file names in the database
408 that contain that string.  If a pattern contains
409 metacharacters, @code{locate} only displays file names that match the
410 pattern exactly.  As a result, patterns that contain metacharacters
411 should usually begin with a @samp{*}, and will most often end with one
412 as well.  The exceptions are patterns that are intended to explicitly
413 match the beginning or end of a file name.   
415 If you only want @code{locate} to match against the last component of
416 the filenames (the ``base name'' of the files) you can use the
417 @samp{--basename} option.  The opposite behaviour is the default, but
418 can be selected explicitly by using the option @samp{--wholename}.
420 The command
421 @example
422 locate @var{pattern}
423 @end example
425 is almost equivalent to
426 @example
427 find @var{directories} -name @var{pattern}
428 @end example
430 where @var{directories} are the directories for which the file name
431 databases contain information.  The differences are that the
432 @code{locate} information might be out of date, and that @code{locate}
433 handles wildcards in the pattern slightly differently than @code{find}
434 (@pxref{Shell Pattern Matching}).
436 The file name databases contain lists of files that were on the system
437 when the databases were last updated.  The system administrator can
438 choose the file name of the default database, the frequency with which
439 the databases are updated, and the directories for which they contain
440 entries.
442 Here is how to select which file name databases @code{locate} searches.
443 The default is system-dependent.
445 @table @code
446 @item --database=@var{path}
447 @itemx -d @var{path}
448 Instead of searching the default file name database, search the file
449 name databases in @var{path}, which is a colon-separated list of
450 database file names.  You can also use the environment variable
451 @code{LOCATE_PATH} to set the list of database files to search.  The
452 option overrides the environment variable if both are used.
453 @end table
455 @node Shell Pattern Matching
456 @subsection Shell Pattern Matching
458 @code{find} and @code{locate} can compare file names, or parts of file
459 names, to shell patterns.  A @dfn{shell pattern} is a string that may
460 contain the following special characters, which are known as
461 @dfn{wildcards} or @dfn{metacharacters}.
463 You must quote patterns that contain metacharacters to prevent the shell
464 from expanding them itself.  Double and single quotes both work; so does
465 escaping with a backslash.
467 @table @code
468 @item *
469 Matches any zero or more characters.
471 @item ?
472 Matches any one character.
474 @item [@var{string}]
475 Matches exactly one character that is a member of the string
476 @var{string}.  This is called a @dfn{character class}.  As a shorthand,
477 @var{string} may contain ranges, which consist of two characters with a
478 dash between them.  For example, the class @samp{[a-z0-9_]} matches a
479 lowercase letter, a number, or an underscore.  You can negate a class by
480 placing a @samp{!} or @samp{^} immediately after the opening bracket.
481 Thus, @samp{[^A-Z@@]} matches any character except an uppercase letter
482 or an at sign.
484 @item \
485 Removes the special meaning of the character that follows it.  This
486 works even in character classes.
487 @end table
489 In the @code{find} tests that do shell pattern matching (@samp{-name},
490 @samp{-wholename}, etc.), wildcards in the pattern will match a @samp{.}
491 at the beginning of a file name.  This is also the case for
492 @code{locate}.  Thus, @samp{find -name '*macs'} will match a file
493 named @file{.emacs}, as will @samp{locate '*macs'}.
495 Slash characters have no special significance in the shell pattern
496 matching that @code{find} and @code{locate} do, unlike in the shell, in
497 which wildcards do not match them.  Therefore, a pattern @samp{foo*bar}
498 can match a file name @samp{foo3/bar}, and a pattern @samp{./sr*sc} can
499 match a file name @samp{./src/misc}.
501 If you want to locate some files with the @samp{locate} command but
502 don't need to see the full list you can use the @samp{--limit} option
503 to see just a small number of results, or the @samp{--count} option to
504 display only the total number of matches.
506 @node Links
507 @section Links
509 There are two ways that files can be linked together.  @dfn{Symbolic
510 links} are a special type of file whose contents are a portion of the
511 name of another file.  @dfn{Hard links} are multiple directory entries
512 for one file; the file names all have the same index node (@dfn{inode})
513 number on the disk.
515 @menu
516 * Symbolic Links::
517 * Hard Links::
518 @end menu
520 @node Symbolic Links
521 @subsection Symbolic Links
523 Symbolic links are names that reference other files.  GNU @code{find}
524 will handle symbolic links in one of two ways; firstly, it can
525 dereference the links for you - this means that if it comes across a
526 symbolic link, it examines the file that the link points to, in order
527 to see if it matches the criteria you have specified.  Secondly, it
528 can check the link itself in case you might be looking for the actual
529 link.  If the file that the symbolic link points to is also within the
530 directory hierarchy you are searching with the @code{find} command,
531 you may not see a great deal of difference between these two
532 alternatives.
534 By default, @code{find} examines symbolic links themselves when it
535 finds them (and, if it later comes across the linked-to file, it will
536 examine that, too).  If you would prefer @code{find} to dereference
537 the links and examine the file that each link points to, specify the
538 @samp{-L} option to @code{find}.  You can explicitly specify the
539 default behaviour by using the @samp{-P} option.    The @samp{-H}
540 option is a half-way-between option which ensures that any symbolic
541 links listed on the command line are dereferenced, but other symbolic
542 links are not.
544 Symbolic links are different to ``hard links'' in the sense that you
545 need permissions upon the linked-to file in order to be able to
546 dereference the link.  This can mean that even if you specify the
547 @samp{-L} option, find may not be able to determine the properties of
548 the file that the link points to (because you don't have sufficient
549 permissions).  In this situation, @samp{find} uses the properties of
550 the link itself.  This also occurs if a symbolic link exists but
551 points to a file that is missing.
553 The options controlling the behaviour of @code{find} with respect to
554 links are as follows :-
556 @table @samp
557 @item -P
558 @code{find} does not dereference symbolic links at all.  This is the
559 default behaviour.  This option must be specified before any of the
560 path names on the command line.
561 @item -H
562 @code{find} does not dereference symbolic links (except in the case of
563 file names on the command line, which are dereferenced).  If a
564 symbolic link cannot be dereferenced, the information for the symbolic
565 link itself is used.  This option must be specified before any of the
566 path names on the command line.
567 @item -L
568 @code{find} dereferences symbolic links where possible, and where this
569 is not possible it uses the properties of the symbolic link itself.
570 This option must be specified before any of the path names on the
571 command line.  Use of this option also implies the same behaviour as
572 the @samp{-noleaf} option.   If you later use the @samp{-H} or
573 @samp{-P} options, this does not turn off @samp{-noleaf}.
575 @item -follow
576 This option forms part of the ``expression'' and must be specified
577 after the path names, but it is otherwise equivalent to @samp{-L}.
578 @end table
580 The following differences in behavior occur when the @samp{-L} option
581 is used:
583 @itemize @bullet
584 @item
585 @code{find} follows symbolic links to directories when searching
586 directory trees.
587 @item
588 @samp{-lname} and @samp{-ilname} always return false (unless they
589 happen to match broken symbolic links).
590 @item
591 @samp{-type} reports the types of the files that symbolic links point
593 @item
594 Implies @samp{-noleaf} (@pxref{Directories}).
595 @end itemize
597 If the @samp{-L} option or the @samp{-H} option is used, 
598 the filenames used as arguments to @samp{-newer}, @samp{-anewer}, and
599 @samp{-cnewer} are dereferenced and the timestamp from the pointed-to
600 file is used instead (if possible -- otherwise the timestamp from the
601 symbolic link is used).
603 @deffn Test -lname pattern
604 @deffnx Test -ilname pattern
605 True if the file is a symbolic link whose contents match shell pattern
606 @var{pattern}.  For @samp{-ilname}, the match is case-insensitive.
607 @xref{Shell Pattern Matching}, for details about the @var{pattern}
608 argument.  If the @samp{-L} option is in effect, this test will always
609 fail for symbolic links unless they are broken.  So, to list any
610 symbolic links to @file{sysdep.c} in the current directory and its
611 subdirectories, you can do:
613 @example
614 find . -lname '*sysdep.c'
615 @end example
616 @end deffn
618 @node Hard Links
619 @subsection Hard Links
621 Hard links allow more than one name to refer to the same file.  To
622 find all the names which refer to the same file as NAME, use
623 @samp{-samefile NAME}.  If you are not using the @samp{-L} option, you
624 can confine your search to one filesystem using the @samp{-xdev}
625 option.  This is useful because hard links cannot point outside a
626 single filesystem, so this can cut down on needless searching.
628 If the @samp{-L} option is in effect, and NAME is in fact a symbolic
629 link, the symbolic link will be dereferenced.  Hence you are searching
630 for other links (hard or symbolic) to the file pointed to by NAME.  If
631 @samp{-L} is in effect but NAME is not itself a symbolic link, other
632 symbolic links to the file NAME will be matched.
634 You can also search for files by inode number.  This can occasionally
635 be useful in diagnosing problems with filesystems for example, because
636 @code{fsck} tends to print inode numbers.  Inode numbers also
637 occasionally turn up in log messages for some types of software, and
638 are used to support the @code{ftok()} library function.
640 You can learn a file's inode number and the number of links to it by
641 running @samp{ls -li} or @samp{find -ls}.  
643 You can search for hard links to inode number NUM by using @samp{-inum
644 NUM}. If there are any file system mount points below the directory
645 where you are starting the search, use the @samp{-xdev} option unless
646 you are also using the @samp{-L} option.  Using @samp{-xdev} this
647 saves needless searching, since hard links to a file must be on the
648 same filesystem.  @xref{Filesystems}.
650 @deffn Test -samefile NAME
651 File is a hard link to the same inode as NAME.  If the @samp{-L}
652 option is in effect, symbolic links to the same file as NAME points to
653 are also matched.
654 @end deffn
656 @deffn Test -inum n
657 File has inode number @var{n}.  The @samp{+} and @samp{-} qualifiers
658 also work, though these are rarely useful.
659 @end deffn
661 You can also search for files that have a certain number of links, with
662 @samp{-links}.  Directories normally have at least two hard links; their
663 @file{.} entry is the second one.  If they have subdirectories, each of
664 those also has a hard link called @file{..} to its parent directory.
665 The @file{.} and @file{..} directory entries are not normally searched
666 unless they are mentioned on the @code{find} command line.
668 @deffn Test -links n
669 File has @var{n} hard links.
670 @end deffn
672 @deffn Test -links +n
673 File has more than @var{n} hard links.
674 @end deffn
676 @deffn Test -links -n
677 File has fewer than @var{n} hard links.
678 @end deffn
680 @node Time
681 @section Time
683 Each file has three time stamps, which record the last time that certain
684 operations were performed on the file:
686 @enumerate
687 @item
688 access (read the file's contents)
689 @item
690 change the status (modify the file or its attributes)
691 @item
692 modify (change the file's contents)
693 @end enumerate
695 There is no timestamp that indicates when a file was @emph{created}.
697 You can search for files whose time stamps are within a certain age
698 range, or compare them to other time stamps.  
700 @menu
701 * Age Ranges::
702 * Comparing Timestamps::
703 @end menu
705 @node Age Ranges
706 @subsection Age Ranges
708 These tests are mainly useful with ranges (@samp{+@var{n}} and
709 @samp{-@var{n}}).
711 @deffn Test -atime n
712 @deffnx Test -ctime n
713 @deffnx Test -mtime n
714 True if the file was last accessed (or its status changed, or it was
715 modified) @var{n}*24 hours ago.  The number of 24-hour periods since
716 the file's timestamp is always rounded down; therefore 0 means ``less
717 than 24 hours ago'', 1 means ``between 24 and 48 hours ago'', and so
718 forth.
719 @end deffn
721 @deffn Test -amin n
722 @deffnx Test -cmin n
723 @deffnx Test -mmin n
724 True if the file was last accessed (or its status changed, or it was
725 modified) @var{n} minutes ago.  These tests provide finer granularity of
726 measurement than @samp{-atime} et al., but rounding is done in a 
727 similar way.  For example, to list files in
728 @file{/u/bill} that were last read from 2 to 6 minutes ago:
730 @example
731 find /u/bill -amin +2 -amin -6
732 @end example
733 @end deffn
735 @deffn Option -daystart
736 Measure times from the beginning of today rather than from 24 hours ago.
737 So, to list the regular files in your home directory that were modified
738 yesterday, do
740 @example
741 find ~ -daystart -type f -mtime 1
742 @end example
743 @end deffn
745 The @samp{-daystart} option is unlike most other options in that it
746 has an effect on the way that other tests are performed.  The affected
747 tests are @samp{-amin}, @samp{-cmin}, @samp{-mmin}, @samp{-atime},
748 @samp{-ctime} and @samp{-mtime}.
750 @node Comparing Timestamps
751 @subsection Comparing Timestamps
753 As an alternative to comparing timestamps to the current time, you can
754 compare them to another file's timestamp.  That file's timestamp could
755 be updated by another program when some event occurs.  Or you could set
756 it to a particular fixed date using the @code{touch} command.  For
757 example, to list files in @file{/usr} modified after February 1 of the
758 current year:
760 @c Idea from Rick Sladkey.
761 @example
762 touch -t 02010000 /tmp/stamp$$
763 find /usr -newer /tmp/stamp$$
764 rm -f /tmp/stamp$$
765 @end example
767 @deffn Test -anewer file
768 @deffnx Test -cnewer file
769 @deffnx Test -newer file
770 True if the file was last accessed (or its status changed, or it was
771 modified) more recently than @var{file} was modified.  These tests are
772 affected by @samp{-follow} only if @samp{-follow} comes before them on
773 the command line.  @xref{Symbolic Links}, for more information on
774 @samp{-follow}.  As an example, to list any files modified since
775 @file{/bin/sh} was last modified:
777 @example
778 find . -newer /bin/sh
779 @end example
780 @end deffn
782 @deffn Test -used n
783 True if the file was last accessed @var{n} days after its status was
784 last changed.  Useful for finding files that are not being used, and
785 could perhaps be archived or removed to save disk space.
786 @end deffn
788 @node Size
789 @section Size
791 @deffn Test -size n@r{[}bckwMG@r{]}
792 True if the file uses @var{n} units of space, rounding up.  The units
793 are 512-byte blocks by default, but they can be changed by adding a
794 one-character suffix to @var{n}:
796 @table @code
797 @item b
798 512-byte blocks (never 1024)
799 @item c
800 bytes
801 @item k
802 kilobytes (1024 bytes)
803 @item w
804 2-byte words
805 @item M
806 Megabytes
807 @item G
808 Gigabytes
809 @end table
811 The `b' suffix always considers blocks to be 512 bytes.  This is not
812 affected by the setting (or non-setting) of the POSIXLY_CORRECT
813 environment variable.  This behaviour is different to the behaviour of
814 the @samp{-ls} action).  If you want to use 1024-byte units, use the
815 `k' suffix instead.
817 The number can be prefixed with a `+' or a `-'.  A plus sign indicates
818 that the test should succeed if the file uses at least @var{n} units
819 of storage (this is the way I normally use this test) and a minus sign
820 indicates that the test should succeed if the file uses less than
821 @var{n} units of storage.   There is no `=' prefix, because that's the 
822 default anyway.  
824 The size does not count indirect blocks, but it does count blocks in
825 sparse files that are not actually allocated.  This handling of sparse
826 files differs from the output of the @samp{%k} and @samp{%b} format
827 specifiers for the @samp{-printf} predicate.
829 @end deffn
831 @deffn Test -empty
832 True if the file is empty and is either a regular file or a directory.
833 This might make it a good candidate for deletion.  This test is useful
834 with @samp{-depth} (@pxref{Directories}) and @samp{-delete}
835 (@pxref{Single File}).
836 @end deffn
838 @node Type
839 @section Type
841 @deffn Test -type c
842 True if the file is of type @var{c}:
844 @table @code
845 @item b
846 block (buffered) special
847 @item c
848 character (unbuffered) special
849 @item d
850 directory
851 @item p
852 named pipe (FIFO)
853 @item f
854 regular file
855 @item l
856 symbolic link
857 @item s
858 socket
859 @item D
860 door (Solaris)
861 @end table
862 @end deffn
864 @deffn Test -xtype c
865 The same as @samp{-type} unless the file is a symbolic link.  For
866 symbolic links: if @samp{-follow} has not been given, true if the file
867 is a link to a file of type @var{c}; if @samp{-follow} has been given,
868 true if @var{c} is @samp{l}.  In other words, for symbolic links,
869 @samp{-xtype} checks the type of the file that @samp{-type} does not
870 check.  @xref{Symbolic Links}, for more information on @samp{-follow}.
871 @end deffn
873 @node Owner
874 @section Owner
876 @deffn Test -user uname
877 @deffnx Test -group gname
878 True if the file is owned by user @var{uname} (belongs to group @var{gname}).
879 A numeric ID is allowed.
880 @end deffn
882 @deffn Test -uid n
883 @deffnx Test -gid n
884 True if the file's numeric user ID (group ID) is @var{n}.  These tests
885 support ranges (@samp{+@var{n}} and @samp{-@var{n}}), unlike
886 @samp{-user} and @samp{-group}.
887 @end deffn
889 @deffn Test -nouser
890 @deffnx Test -nogroup
891 True if no user corresponds to the file's numeric user ID (no group
892 corresponds to the numeric group ID).  These cases usually mean that the
893 files belonged to users who have since been removed from the system.
894 You probably should change the ownership of such files to an existing
895 user or group, using the @code{chown} or @code{chgrp} program.
896 @end deffn
898 @node Permissions
899 @section Permissions
901 @xref{File Permissions}, for information on how file permissions are
902 structured and how to specify them.
904 @deffn Test -perm mode
906 True if the file's permissions are exactly @var{mode} (which can be
907 numeric or symbolic).
909 If @var{mode} starts with @samp{-}, true if
910 @emph{all} of the permissions set in @var{mode} are set for the file;
911 permissions not set in @var{mode} are ignored.
912 If @var{mode} starts with @samp{+}, true if
913 @emph{any} of the permissions set in @var{mode} are set for the file;
914 permissions not set in @var{mode} are ignored.
917 If you don't use the @samp{+} or @samp{-} form with a symbolic mode
918 string, you may have to specify a rather complex mode string.  For
919 example @samp{-perm g=w} will only match files which have mode 0020
920 (that is, ones for which group write permission is the only permission
921 set).  It is more likely that you will want to use the @samp{+} or
922 @samp{-} forms, for example @samp{-perm -g=w}, which matches any file
923 with group write permission.
926 @table @samp
927 @item -perm 664
928 Match files which have read and write permission for their owner,
929 and group, but which the rest of the world can read but not write to.  
930 Files which meet these criteria but have other permissions bits set
931 (for example if someone can execute the file) will not be matched.
933 @item -perm -664
934 Match files which have read and write permission for their owner,
935 and group, but which the rest of the world can read but not write to,
936 without regard to the presence of any extra permission bits (for
937 example the executable bit).  This will match a file which has mode
938 0777, for example.
940 @item -perm +222
941 Match files which are writeable by somebody (their owner, or
942 their group, or anybody else).
944 @item -perm +022
945 Match files which are writeable by either their owner or their
946 group.  The files don't have to be writeable by both the owner and
947 group to be matched; either will do.
949 @item -perm +g+w,o+w
950 As above.
952 @item -perm +g=w,o=w
953 As above
955 @item -perm -022
956 Search for files which are writeable by both their owner and their
957 group.
959 @item -perm -g+w,o+w
960 As above.
961 @end table
962 @end deffn
964 @node Contents
965 @section Contents
967 To search for files based on their contents, you can use the @code{grep}
968 program.  For example, to find out which C source files in the current
969 directory contain the string @samp{thing}, you can do:
971 @example
972 grep -l thing *.[ch]
973 @end example
975 If you also want to search for the string in files in subdirectories,
976 you can combine @code{grep} with @code{find} and @code{xargs}, like
977 this:
979 @example
980 find . -name '*.[ch]' | xargs grep -l thing
981 @end example
983 The @samp{-l} option causes @code{grep} to print only the names of files
984 that contain the string, rather than the lines that contain it.  The
985 string argument (@samp{thing}) is actually a regular expression, so it
986 can contain metacharacters.  This method can be refined a little by
987 using the @samp{-r} option to make @code{xargs} not run @code{grep} if
988 @code{find} produces no output, and using the @code{find} action
989 @samp{-print0} and the @code{xargs} option @samp{-0} to avoid
990 misinterpreting files whose names contain spaces:
992 @example
993 find . -name '*.[ch]' -print0 | xargs -r -0 grep -l thing
994 @end example
996 For a fuller treatment of finding files whose contents match a pattern,
997 see the manual page for @code{grep}.
999 @node Directories
1000 @section Directories
1002 Here is how to control which directories @code{find} searches, and how
1003 it searches them.  These two options allow you to process a horizontal
1004 slice of a directory tree.
1006 @deffn Option -maxdepth levels
1007 Descend at most @var{levels} (a non-negative integer) levels of
1008 directories below the command line arguments.  @samp{-maxdepth 0} means
1009 only apply the tests and actions to the command line arguments.
1010 @end deffn
1012 @deffn Option -mindepth levels
1013 Do not apply any tests or actions at levels less than @var{levels} (a
1014 non-negative integer).  @samp{-mindepth 1} means process all files
1015 except the command line arguments.
1016 @end deffn
1018 @deffn Option -depth
1019 Process each directory's contents before the directory itself.  Doing
1020 this is a good idea when producing lists of files to archive with
1021 @code{cpio} or @code{tar}.  If a directory does not have write
1022 permission for its owner, its contents can still be restored from the
1023 archive since the directory's permissions are restored after its contents.
1024 @end deffn
1026 @deffn Option -d
1027 This is a deprecated synonym for @samp{-depth}, for compatibility with
1028 Mac OS X, FreeBSD and OpenBSD.   The @samp{-depth} option is a POSIX
1029 feature, so it is better to use that.
1030 @end deffn
1032 @deffn Action -prune
1033 If the file is a directory, do not descend into it.  The result is
1034 true.  For example, to skip the directory @file{src/emacs} and all
1035 files and directories under it, and print the names of the other files
1036 found:
1038 @example
1039 find . -wholename './src/emacs' -prune -o -print
1040 @end example
1042 The above command will not print @file{./src/emacs} among its list of
1043 results.  This however is not due to the effect of the @samp{-prune}
1044 action (which only prevents further descent, it doesn't make sure we
1045 ignore that item).  Instead, this effect is due to the use of
1046 @samp{-o}.  Since the left hand side of the ``or'' condition has
1047 succeeded for @file{./src/emacs}, it is not necessary to evaluate the
1048 right-hand-side (@samp{-print}) at all for this particular file.  If
1049 you wanted to print that directory name you could use either an extra
1050 @samp{-print} action:
1052 @example
1053 find . -wholename './src/emacs' -prune -print -o -print
1054 @end example
1056 or use the comma operator:
1058 @example
1059 find . -wholename './src/emacs' -prune , -print
1060 @end example
1062 If the @samp{-depth} option is in effect, the subdirectories will have
1063 already been visited in any case.  Hence @samp{-prune} has no effect
1064 and returns false.
1065 @end deffn
1068 @deffn Action -quit
1069 Exit immediately (with return value zero if no errors have occurred).
1070 No child processes will be left running, but no more paths specified
1071 on the command line will be processed.  For example, @code{find
1072 /tmp/foo /tmp/bar -print -quit} will print only @samp{/tmp/foo}.
1073 @end deffn 
1075 @deffn Option -noleaf
1076 Do not optimize by assuming that directories contain 2 fewer
1077 subdirectories than their hard link count.  This option is needed when
1078 searching filesystems that do not follow the Unix directory-link
1079 convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount
1080 points.  Each directory on a normal Unix filesystem has at least 2 hard
1081 links: its name and its @file{.}  entry.  Additionally, its
1082 subdirectories (if any) each have a @file{..}  entry linked to that
1083 directory.  When @code{find} is examining a directory, after it has
1084 statted 2 fewer subdirectories than the directory's link count, it knows
1085 that the rest of the entries in the directory are non-directories
1086 (@dfn{leaf} files in the directory tree).  If only the files' names need
1087 to be examined, there is no need to stat them; this gives a significant
1088 increase in search speed.
1089 @end deffn
1091 @deffn Option -ignore_readdir_race
1092 If a file disappears after its name has been read from a directory but
1093 before @code{find} gets around to examining the file with @code{stat},
1094 don't issue an error message.  If you don't specify this option, an
1095 error message will be issued.  This option can be useful in system
1096 scripts (cron scripts, for example) that examine areas of the
1097 filesystem that change frequently (mail queues, temporary directories,
1098 and so forth), because this scenario is common for those sorts of
1099 directories.  Completely silencing error messages from @code{find} is
1100 undesirable, so this option neatly solves the problem.  There is no
1101 way to search one part of the filesystem with this option on and part
1102 of it with this option off, though.
1103 @end deffn
1105 @deffn Option -noignore_readdir_race
1106 This option reverses the effect of the @samp{-ignore_readdir_race} option.
1107 @end deffn
1110 @node Filesystems
1111 @section Filesystems
1113 A @dfn{filesystem} is a section of a disk, either on the local host or
1114 mounted from a remote host over a network.  Searching network
1115 filesystems can be slow, so it is common to make @code{find} avoid them.
1117 There are two ways to avoid searching certain filesystems.  One way is
1118 to tell @code{find} to only search one filesystem:
1120 @deffn Option -xdev
1121 @deffnx Option -mount
1122 Don't descend directories on other filesystems.  These options are synonyms.
1123 @end deffn
1125 The other way is to check the type of filesystem each file is on, and
1126 not descend directories that are on undesirable filesystem types:
1128 @deffn Test -fstype type
1129 True if the file is on a filesystem of type @var{type}.  The valid
1130 filesystem types vary among different versions of Unix; an incomplete
1131 list of filesystem types that are accepted on some version of Unix or
1132 another is:
1133 @example
1134 ext2 ext3 proc sysfs ufs 4.2 4.3 nfs tmp mfs S51K S52K
1135 @end example
1136 You can use @samp{-printf} with the @samp{%F} directive to see the types
1137 of your filesystems.  The @samp{%D} directive shows the device number.
1138 @xref{Print File Information}.  @samp{-fstype} is
1139 usually used with @samp{-prune} to avoid searching remote filesystems
1140 (@pxref{Directories}). 
1141 @end deffn
1143 @node Combining Primaries With Operators
1144 @section Combining Primaries With Operators
1146 Operators build a complex expression from tests and actions.
1147 The operators are, in order of decreasing precedence:
1149 @table @code
1150 @item @asis{( @var{expr} )}
1151 @findex ()
1152 Force precedence.  True if @var{expr} is true.
1154 @item @asis{! @var{expr}}
1155 @itemx @asis{-not @var{expr}}
1156 @findex !
1157 @findex -not
1158 True if @var{expr} is false.
1160 @item @asis{@var{expr1 expr2}}
1161 @itemx @asis{@var{expr1} -a @var{expr2}}
1162 @itemx @asis{@var{expr1} -and @var{expr2}}
1163 @findex -a
1164 @findex -and
1165 And; @var{expr2} is not evaluated if @var{expr1} is false.
1167 @item @asis{@var{expr1} -o @var{expr2}}
1168 @itemx @asis{@var{expr1} -or @var{expr2}}
1169 @findex -o
1170 @findex -or
1171 Or; @var{expr2} is not evaluated if @var{expr1} is true.
1173 @item @asis{@var{expr1} , @var{expr2}}
1174 @findex ,
1175 List; both @var{expr1} and @var{expr2} are always evaluated.  True if
1176 @var{expr2} is true.  The value of @var{expr1} is discarded.  This
1177 operator lets you do multiple independent operations on one traversal,
1178 without depending on whether other operations succeeded.  The two 
1179 operations @var{expr1} and @var{expr2} are not always fully
1180 independent, since @var{expr1} might have side effects like touching
1181 or deleting files, or it might use @samp{-prune} which would also
1182 affect @var{expr2}.
1183 @end table
1185 @code{find} searches the directory tree rooted at each file name by
1186 evaluating the expression from left to right, according to the rules of
1187 precedence, until the outcome is known (the left hand side is false for
1188 @samp{-and}, true for @samp{-or}), at which point @code{find} moves on
1189 to the next file name.
1191 There are two other tests that can be useful in complex expressions:
1193 @deffn Test -true
1194 Always true.
1195 @end deffn
1197 @deffn Test -false
1198 Always false.
1199 @end deffn
1201 @node Actions, Common Tasks, Finding Files, Top
1202 @chapter Actions
1204 There are several ways you can print information about the files that
1205 match the criteria you gave in the @code{find} expression.  You can
1206 print the information either to the standard output or to a file that
1207 you name.  You can also execute commands that have the file names as
1208 arguments.  You can use those commands as further filters to select files.
1210 @menu
1211 * Print File Name::
1212 * Print File Information::
1213 * Run Commands::
1214 * Delete Files::
1215 * Adding Tests::
1216 @end menu
1218 @node Print File Name
1219 @section Print File Name
1221 @deffn Action -print
1222 True; print the full file name on the standard output, followed by a
1223 newline.
1224 @end deffn
1226 @deffn Action -fprint file
1227 True; print the full file name into file @var{file}, followed by a
1228 newline.  If @var{file} does not exist when @code{find} is run, it is
1229 created; if it does exist, it is truncated to 0 bytes.  The file names
1230 @file{/dev/stdout} and @file{/dev/stderr} are handled specially; they
1231 refer to the standard output and standard error output, respectively.
1232 @end deffn
1234 @node Print File Information
1235 @section Print File Information
1237 @deffn Action -ls
1238 True; list the current file in @samp{ls -dils} format on the standard
1239 output.  The output looks like this:
1241 @smallexample
1242 204744   17 -rw-r--r--   1 djm      staff       17337 Nov  2  1992 ./lwall-quotes
1243 @end smallexample
1245 The fields are:
1247 @enumerate
1248 @item
1249 The inode number of the file.  @xref{Hard Links}, for how to find files
1250 based on their inode number.
1252 @item
1253 the number of blocks in the file.  The block counts are of 1K blocks,
1254 unless the environment variable @code{POSIXLY_CORRECT} is set, in which
1255 case 512-byte blocks are used.  @xref{Size}, for how to find files based
1256 on their size.
1258 @item
1259 The file's type and permissions.  The type is shown as a dash for a
1260 regular file; for other file types, a letter like for @samp{-type} is
1261 used (@pxref{Type}).  The permissions are read, write, and execute for
1262 the file's owner, its group, and other users, respectively; a dash means
1263 the permission is not granted.  @xref{File Permissions}, for more details
1264 about file permissions.  @xref{Permissions}, for how to find files based
1265 on their permissions.
1267 @item
1268 The number of hard links to the file.
1270 @item
1271 The user who owns the file.
1273 @item
1274 The file's group.
1276 @item
1277 The file's size in bytes.
1279 @item
1280 The date the file was last modified.
1282 @item
1283 The file's name.  @samp{-ls} quotes non-printable characters in the file
1284 names using C-like backslash escapes.
1285 @end enumerate
1286 @end deffn
1288 @deffn Action -fls file
1289 True; like @samp{-ls} but write to @var{file} like @samp{-fprint}
1290 (@pxref{Print File Name}).
1291 @end deffn
1293 @deffn Action -printf format
1294 True; print @var{format} on the standard output, interpreting @samp{\}
1295 escapes and @samp{%} directives.  Field widths and precisions can be
1296 specified as with the @code{printf} C function.  Format flags (like
1297 @samp{#} for example) may not work as you expect because many of the
1298 fields, even numeric ones, are printed with %s.  This means though
1299 that the format flag @samp{-} will work; it forces left-alignment of
1300 the field.  Unlike @samp{-print}, @samp{-printf} does not add a
1301 newline at the end of the string.  If you want a newline at the end of
1302 the string, add a @samp{\n}.
1303 @end deffn
1305 @deffn Action -fprintf file format
1306 True; like @samp{-printf} but write to @var{file} like @samp{-fprint}
1307 (@pxref{Print File Name}).
1308 @end deffn
1310 @menu
1311 * Escapes::
1312 * Format Directives::
1313 * Time Formats::
1314 @end menu
1316 @node Escapes
1317 @subsection Escapes
1319 The escapes that @samp{-printf} and @samp{-fprintf} recognize are:
1321 @table @code
1322 @item \a
1323 Alarm bell.
1324 @item \b
1325 Backspace.
1326 @item \c
1327 Stop printing from this format immediately and flush the output.
1328 @item \f
1329 Form feed.
1330 @item \n
1331 Newline.
1332 @item \r
1333 Carriage return.
1334 @item \t
1335 Horizontal tab.
1336 @item \v
1337 Vertical tab.
1338 @item \\
1339 A literal backslash (@samp{\}).
1340 @item \NNN
1341 The character whose ASCII code is NNN (octal).
1342 @end table
1344 A @samp{\} character followed by any other character is treated as an
1345 ordinary character, so they both are printed, and a warning message is
1346 printed to the standard error output (because it was probably a typo).
1348 @node Format Directives
1349 @subsection Format Directives
1351 @samp{-printf} and @samp{-fprintf} support the following format
1352 directives to print information about the file being processed.  The C
1353 @code{printf} function, field width and precision specifiers are
1354 supported, as applied to string (%s) types. That is, you can specify
1355 "minimum field width"."maximum field width" for each directive.
1356 Format flags (like @samp{#} for example) may not work as you expect
1357 because many of the fields, even numeric ones, are printed with %s.
1358 The format flag @samp{-} does work; it forces left-alignment of the
1359 field.
1361 @samp{%%} is a literal percent sign.  A @samp{%} character followed by
1362 an unrecognised character (i.e. not a known directive or printf field
1363 width and precision specifier), is discarded (but the unrecognised character
1364 is printed), and a warning message is printed to the standard error output
1365 (because it was probably a typo).
1367 @menu
1368 * Name Directives::
1369 * Ownership Directives::
1370 * Size Directives::
1371 * Location Directives::
1372 * Time Directives::
1373 * Formatting Flags::
1374 @end menu
1376 @node Name Directives
1377 @subsubsection Name Directives
1379 @table @code
1380 @item %p
1381 @c supports %-X.Yp
1382 File's name (not the absolute path name, but the name of the file as
1383 it was encountered by find - that is, as a relative path from one of
1384 the starting points).
1385 @item %f
1386 File's name with any leading directories removed (only the last element).
1387 @c supports %-X.Yf
1388 @item %h
1389 Leading directories of file's name (all but the last element and the
1390 slash before it).
1391 @c supports %-X.Yh
1392 @item %P
1393 File's name with the name of the command line argument under which
1394 it was found removed from the beginning.
1395 @c supports %-X.YP
1396 @item %H
1397 Command line argument under which file was found.
1398 @c supports %-X.YH
1399 @end table
1401 @node Ownership Directives
1402 @subsubsection Ownership Directives
1404 @table @code
1405 @item %g
1406 @c supports %-X.Yg
1407 File's group name, or numeric group ID if the group has no name.
1408 @item %G
1409 @c supports %-X.Yg
1410 @c TODO: Needs to support # flag and 0 flag
1411 File's numeric group ID.
1412 @item %u
1413 @c supports %-X.Yu
1414 File's user name, or numeric user ID if the user has no name.
1415 @item %U
1416 @c supports %-X.Yu
1417 @c TODO: Needs to support # flag
1418 File's numeric user ID.
1419 @item %m
1420 @c full support, including # and 0.
1421 File's permissions (in octal).   If you always want to have a leading
1422 zero on the number, use the '#' format flag, for example '%#m'.
1423 @end table
1425 @node Size Directives
1426 @subsubsection Size Directives
1428 @table @code
1429 @item %k
1430 Amount of disk space occupied by the file, measured in 1K blocks
1431 (rounded up).  This can be less than the length of the file if 
1432 it is a sparse file (that is, it has ``holes'').  
1433 @item %b
1434 File's size in 512-byte blocks (rounded up).  This also can be less 
1435 than the length of the file, if the file is sparse.
1436 @item %s
1437 File's size in bytes.
1438 @end table
1440 @node Location Directives
1441 @subsubsection Location Directives
1443 @table @code
1444 @item %d
1445 File's depth in the directory tree (depth below a file named on the
1446 command line, not depth below the root directory).  Files named on the
1447 command line have a depth of 0.  Subdirectories immediately below them
1448 have a depth of 1, and so on.
1449 @item %D
1450 The device number on which the file exists (the @code{st_dev} field of
1451 @code{struct stat}), in decimal.
1452 @item %F
1453 Type of the filesystem the file is on; this value can be used for
1454 @samp{-fstype} (@pxref{Directories}).
1455 @item %l
1456 Object of symbolic link (empty string if file is not a symbolic link).
1457 @item %i
1458 File's inode number (in decimal).
1459 @item %n
1460 Number of hard links to file.
1461 @item %y 
1462 Type of the file as used with @samp{-type}.   If the file is a symbolic
1463 link, @samp{l} will be printed.
1464 @item %Y
1465 Type of the file as used with @samp{-type}.   If the file is a symbolic
1466 link, it is dereferenced.  If the file is a broken symbolic link,
1467 @samp{N} is printed.
1469 @end table
1471 @node Time Directives
1472 @subsubsection Time Directives
1474 Some of these directives use the C @code{ctime} function.  Its output
1475 depends on the current locale, but it typically looks like
1477 @example
1478 Wed Nov  2 00:42:36 1994
1479 @end example
1481 @table @code
1482 @item %a
1483 File's last access time in the format returned by the C @code{ctime} function.
1484 @item %A@var{k}
1485 File's last access time in the format specified by @var{k}
1486 (@pxref{Time Formats}). 
1487 @item %c
1488 File's last status change time in the format returned by the C @code{ctime}
1489 function.
1490 @item %C@var{k}
1491 File's last status change time in the format specified by @var{k}
1492 (@pxref{Time Formats}).
1493 @item %t
1494 File's last modification time in the format returned by the C @code{ctime}
1495 function.
1496 @item %T@var{k}
1497 File's last modification time in the format specified by @var{k} 
1498 (@pxref{Time Formats}). 
1499 @end table
1501 @node Time Formats
1502 @subsection Time Formats
1504 Below are the formats for the directives @samp{%A}, @samp{%C}, and
1505 @samp{%T}, which print the file's timestamps.  Some of these formats
1506 might not be available on all systems, due to differences in the C
1507 @code{strftime} function between systems.
1509 @menu
1510 * Time Components::
1511 * Date Components::
1512 * Combined Time Formats::
1513 @end menu
1515 @node Time Components
1516 @subsubsection Time Components
1518 The following format directives print single components of the time.
1520 @table @code
1521 @item H
1522 hour (00..23)
1523 @item I
1524 hour (01..12)
1525 @item k
1526 hour ( 0..23)
1527 @item l
1528 hour ( 1..12)
1529 @item p
1530 locale's AM or PM
1531 @item Z
1532 time zone (e.g., EDT), or nothing if no time zone is determinable
1533 @item M
1534 minute (00..59)
1535 @item S
1536 second (00..61)
1537 @item @@
1538 seconds since Jan. 1, 1970, 00:00 GMT.
1539 @end table
1541 @node Date Components
1542 @subsubsection Date Components
1544 The following format directives print single components of the date.
1546 @table @code
1547 @item a
1548 locale's abbreviated weekday name (Sun..Sat)
1549 @item A
1550 locale's full weekday name, variable length (Sunday..Saturday)
1551 @item b
1552 @itemx h
1553 locale's abbreviated month name (Jan..Dec)
1554 @item B
1555 locale's full month name, variable length (January..December)
1556 @item m
1557 month (01..12)
1558 @item d
1559 day of month (01..31)
1560 @item w
1561 day of week (0..6)
1562 @item j
1563 day of year (001..366)
1564 @item U
1565 week number of year with Sunday as first day of week (00..53)
1566 @item W
1567 week number of year with Monday as first day of week (00..53)
1568 @item Y
1569 year (1970@dots{})
1570 @item y
1571 last two digits of year (00..99)
1572 @end table
1574 @node Combined Time Formats
1575 @subsubsection Combined Time Formats
1577 The following format directives print combinations of time and date
1578 components. 
1580 @table @code
1581 @item r
1582 time, 12-hour (hh:mm:ss [AP]M)
1583 @item T
1584 time, 24-hour (hh:mm:ss)
1585 @item X
1586 locale's time representation (H:M:S)
1587 @item c
1588 locale's date and time (Sat Nov 04 12:02:33 EST 1989)
1589 @item D
1590 date (mm/dd/yy)
1591 @item x
1592 locale's date representation (mm/dd/yy)
1593 @item +
1594 Date and time, separated by '+', for example `2004-04-28+22:22:05'.
1595 The time is given in the current timezone (which may be affected by
1596 setting the TZ environment variable).  This is a GNU extension.
1597 @end table
1599 @node Formatting Flags
1600 @subsubsection Formatting Flags
1602 The @samp{%m} and @samp{%d} directives support the @samp{#}, @samp{0}
1603 and @samp{+} flags, but the other directives do not, even if they
1604 print numbers.  Numeric directives that do not support these flags
1605 include 
1607 @samp{G},
1608 @samp{U},
1609 @samp{b},
1610 @samp{D},
1611 @samp{k} and
1612 @samp{n}.
1614 All fields support the format flag @samp{-}, which makes fields
1615 left-aligned.  That is, if the field width is greater than the actual
1616 contents of the field, the requisite number of spaces are printed
1617 after the field content instead of before it.
1619 @node Run Commands
1620 @section Run Commands
1622 You can use the list of file names created by @code{find} or
1623 @code{locate} as arguments to other commands.  In this way you can
1624 perform arbitrary actions on the files.
1626 @menu
1627 * Single File::
1628 * Multiple Files::
1629 * Querying::
1630 @end menu
1632 @node Single File
1633 @subsection Single File
1635 Here is how to run a command on one file at a time.
1637 @deffn Action -execdir command ;
1638 Execute @var{command}; true if 0 status is returned.  @code{find} takes
1639 all arguments after @samp{-exec} to be part of the command until an
1640 argument consisting of @samp{;} is reached.  It replaces the string
1641 @samp{@{@}} by the current file name being processed everywhere it
1642 occurs in the command.  Both of these constructions need to be escaped
1643 (with a @samp{\}) or quoted to protect them from expansion by the shell.
1644 The command is executed in the directory in which @code{find} was run.
1646 For example, to compare each C header file in the current directory with
1647 the file @file{/tmp/master}:
1649 @example
1650 find . -name '*.h' -execdir diff -u '@{@}' /tmp/master ';'
1651 @end example
1652 @end deffn
1655 Another similar option, @samp{-exec} is supported, but is less
1656 secure.  @xref{Security Considerations} for a discussion of the
1657 security problems surrounding @samp{-exec}.
1660 @deffn Action -exec command ;
1661 This insecure variant of the @samp{-execdir} action is specified by
1662 POSIX.  The main difference is that the command is executed in the
1663 directory from which @code{find} was invoked, meaning that @samp{@{@}}
1664 is expanded to a relative path starting with the name of one of the
1665 starting directories, rather than just the basename of the matched
1666 file.
1667 @end deffn
1670 @node Multiple Files
1671 @subsection Multiple Files
1673 Sometimes you need to process files one of the time.  But usually this
1674 is not necessary, and, it is faster to run a command on as many files
1675 as possible at a time, rather than once per file.  Doing this saves on
1676 the time it takes to start up the command each time.
1678 The @samp{-execdir} and @samp{-exec} actions have variants that build
1679 command lines containing as many matched files as possible.  
1681 @deffn Action -execdir command @{@} +
1682 This works as for @samp{-execdir command ;}, except that the
1683 @samp{@{@}} at the end of the command is expanded to a list of names
1684 of matching files.  This expansion is done in such a way as to avoid
1685 exceeding the maximum command line length available on the system.
1686 Only one @samp{@{@}} is allowed within the command, and it must appear
1687 at the end, immediately before the @samp{+}.  A @samp{+} appearing in
1688 any position other than immediately after @samp{@{@}} is not
1689 considered to be special (that is, it does not terminate the command).
1690 @end deffn
1693 @deffn Action -exec command @{@} +
1694 This insecure variant of the @samp{-execdir} action is specified by
1695 POSIX.  The main difference is that the command is executed in the
1696 directory from which @code{find} was invoked, meaning that @samp{@{@}}
1697 is expanded to a relative path starting with the name of one of the
1698 starting directories, rather than just the basename of the matched
1699 file.
1700 @end deffn
1703 Another, but less secure, way to run a command on more than one file
1704 at once, is to use the @code{xargs} command, which is invoked like this:
1706 @example
1707 xargs @r{[}@var{option}@dots{}@r{]} @r{[}@var{command} @r{[}@var{initial-arguments}@r{]}@r{]}
1708 @end example
1710 @code{xargs} normally reads arguments from the standard input.  These
1711 arguments are delimited by blanks (which can be protected with double
1712 or single quotes or a backslash) or newlines.  It executes the
1713 @var{command} (default is @file{/bin/echo}) one or more times with any
1714 @var{initial-arguments} followed by arguments read from standard
1715 input.  Blank lines on the standard input are ignored.
1717 Instead of blank-delimited names, it is safer to use @samp{find -print0}
1718 or @samp{find -fprint0} and process the output by giving the @samp{-0}
1719 or @samp{--null} option to GNU @code{xargs}, GNU @code{tar}, GNU
1720 @code{cpio}, or @code{perl}.  The @code{locate} command also has a
1721 @samp{-0} or @samp{--null} option which does the same thing.
1723 You can use shell command substitution (backquotes) to process a list of
1724 arguments, like this:
1726 @example
1727 grep -l sprintf `find $HOME -name '*.c' -print`
1728 @end example
1730 However, that method produces an error if the length of the @samp{.c}
1731 file names exceeds the operating system's command-line length limit.
1732 @code{xargs} avoids that problem by running the command as many times as
1733 necessary without exceeding the limit:
1735 @example
1736 find $HOME -name '*.c' -print | xargs grep -l sprintf
1737 @end example
1739 However, if the command needs to have its standard input be a terminal
1740 (@code{less}, for example), you have to use the shell command
1741 substitution method or use the @samp{--arg-file} option of
1742 @code{xargs}.
1744 The @code{xargs} command will process all its input, building command
1745 lines and executing them, unless one of the commands exits with a
1746 status of 255 (this will cause xargs to issue an error message and
1747 stop) or it reads a line contains the end of file string specified
1748 with the @samp{--eof} option. 
1750 @menu
1751 * Unsafe File Name Handling::
1752 * Safe File Name Handling::
1753 * Limiting Command Size::
1754 * Interspersing File Names::
1755 @end menu
1757 @node Unsafe File Name Handling
1758 @subsubsection Unsafe File Name Handling
1760 Because file names can contain quotes, backslashes, blank characters,
1761 and even newlines, it is not safe to process them using @code{xargs} in its
1762 default mode of operation.  But since most files' names do not contain
1763 blanks, this problem occurs only infrequently.  If you are only
1764 searching through files that you know have safe names, then you need not
1765 be concerned about it.  
1767 @c This example is adapted from:
1768 @c From: pfalstad@stone.Princeton.EDU (Paul John Falstad)
1769 @c Newsgroups: comp.unix.shell
1770 @c Subject: Re: Beware xargs security holes
1771 @c Date: 16 Oct 90 19:12:06 GMT
1772 @c 
1773 In many applications, if @code{xargs} botches processing a file because
1774 its name contains special characters, some data might be lost.  The
1775 importance of this problem depends on the importance of the data and
1776 whether anyone notices the loss soon enough to correct it.  However,
1777 here is an extreme example of the problems that using blank-delimited
1778 names can cause.  If the following command is run daily from
1779 @code{cron}, then any user can remove any file on the system:
1781 @example
1782 find / -name '#*' -atime +7 -print | xargs rm
1783 @end example
1785 For example, you could do something like this:
1787 @example
1788 eg$ echo > '#
1789 vmunix'
1790 @end example
1792 @noindent
1793 and then @code{cron} would delete @file{/vmunix}, if it ran
1794 @code{xargs} with @file{/} as its current directory.
1796 To delete other files, for example @file{/u/joeuser/.plan}, you could do
1797 this:
1799 @example
1800 eg$ mkdir '#
1802 eg$ cd '#
1804 eg$ mkdir u u/joeuser u/joeuser/.plan'
1806 eg$ echo > u/joeuser/.plan'
1807 /#foo'
1808 eg$ cd ..
1809 eg$ find . -name '#*' -print | xargs echo
1810 ./# ./# /u/joeuser/.plan /#foo
1811 @end example
1813 @node Safe File Name Handling
1814 @subsubsection Safe File Name Handling
1816 Here is how to make @code{find} output file names so that they can be
1817 used by other programs without being mangled or misinterpreted.  You can
1818 process file names generated this way by giving the @samp{-0} or
1819 @samp{--null} option to GNU @code{xargs}, GNU @code{tar}, GNU
1820 @code{cpio}, or @code{perl}.
1822 @deffn Action -print0
1823 True; print the full file name on the standard output, followed by a
1824 null character.
1825 @end deffn
1827 @deffn Action -fprint0 file
1828 True; like @samp{-print0} but write to @var{file} like @samp{-fprint}
1829 (@pxref{Print File Name}).
1830 @end deffn
1832 As of findutils version 4.2.4, the @code{locate} program also has a
1833 @samp{--null} option which does the same thing.  For similarity with
1834 @code{xargs}, the short form of the option @samp{-0} can also be used.
1836 If you want to be able to handle file names safely but need to run
1837 commands which want to be connected to a terminal on their input, you
1838 can use the @samp{--arg-file} option to @code{xargs} like this:
1840 @example
1841 find / -name xyzzy -print0 > list
1842 xargs --null --arg-file=list munge
1843 @end example
1845 The example above runs the @code{munge} program on all the files named
1846 @file{xyzzy} that we can find, but @code{munge}'s input will still be
1847 the terminal (or whatever the shell was using as standard input).  If
1848 your shell has the ``process substitution'' feature @samp{<(...)}, you
1849 can do this in just one step:
1851 @example
1852 xargs --null --arg-file=<(find / -name xyzzy -print0) munge
1853 @end example
1855 @node Limiting Command Size
1856 @subsubsection Limiting Command Size
1858 @code{xargs} gives you control over how many arguments it passes to the
1859 command each time it executes it.  By default, it uses up to
1860 @code{ARG_MAX} - 2k, or 128k, whichever is smaller, characters per
1861 command.  It uses as many lines and arguments as fit within that limit.
1862 The following options modify those values.
1864 @table @code
1865 @item --no-run-if-empty
1866 @itemx -r
1867 If the standard input does not contain any nonblanks, do not run the
1868 command.  By default, the command is run once even if there is no input.
1870 @item --max-lines@r{[}=@var{max-lines}@r{]}
1871 @itemx -l@r{[}@var{max-lines}@r{]}
1872 Use at most @var{max-lines} nonblank input lines per command line;
1873 @var{max-lines} defaults to 1 if omitted.  Trailing blanks cause an
1874 input line to be logically continued on the next input line, for the
1875 purpose of counting the lines.  Implies @samp{-x}.
1877 @item --max-args=@var{max-args}
1878 @itemx -n @var{max-args}
1879 Use at most @var{max-args} arguments per command line.  Fewer than
1880 @var{max-args} arguments will be used if the size (see the @samp{-s}
1881 option) is exceeded, unless the @samp{-x} option is given, in which case
1882 @code{xargs} will exit.
1884 @item --max-chars=@var{max-chars}
1885 @itemx -s @var{max-chars}
1886 Use at most @var{max-chars} characters per command line, including the
1887 command and initial arguments and the terminating nulls at the ends of
1888 the argument strings.  If you specify a value for this option which is
1889 too large or small, a warning message is printed and the appropriate
1890 upper or lower limit is used instead.
1892 @item --max-procs=@var{max-procs}
1893 @itemx -P @var{max-procs}
1894 Run up to @var{max-procs} processes at a time; the default is 1.  If
1895 @var{max-procs} is 0, @code{xargs} will run as many processes as
1896 possible at a time.  Use the @samp{-n}, @samp{-s}, or @samp{-l} option
1897 with @samp{-P}; otherwise chances are that the command will be run only
1898 once.
1899 @end table
1901 @node Interspersing File Names
1902 @subsubsection Interspersing File Names
1904 @code{xargs} can insert the name of the file it is processing between
1905 arguments you give for the command.  Unless you also give options to
1906 limit the command size (@pxref{Limiting Command Size}), this mode of
1907 operation is equivalent to @samp{find -exec} (@pxref{Single File}).
1909 @table @code
1910 @item --replace@r{[}=@var{replace-str}@r{]}
1911 @itemx -i@r{[}@var{replace-str}@r{]}
1912 Replace occurrences of @var{replace-str} in the initial arguments with
1913 names read from the input.  Also, unquoted blanks do not
1914 terminate arguments; instead, the input is split at newlines only.  If
1915 @var{replace-str} is omitted, it defaults to @samp{@{@}} (like for
1916 @samp{find -exec}).  Implies @samp{-x} and @samp{-l 1}.  As an
1917 example, to sort each file the @file{bills} directory, leaving the
1918 output in that file name with @file{.sorted} appended, you could do:
1920 @example
1921 find bills -type f | xargs -iXX sort -o XX.sorted XX
1922 @end example
1924 @noindent
1925 The equivalent command using @samp{find -exec} is:
1927 @example
1928 find bills -type f -exec sort -o '@{@}.sorted' '@{@}' ';'
1929 @end example
1930 @end table
1932 @node Querying
1933 @subsection Querying
1935 To ask the user whether to execute a command on a single file, you can
1936 use the @code{find} primary @samp{-ok} instead of @samp{-exec}:
1938 @deffn Action -ok command ;
1939 Like @samp{-exec} (@pxref{Single File}), but ask the user first (on
1940 the standard input); if the response does not start with @samp{y} or
1941 @samp{Y}, do not run the command, and return false.
1942 @end deffn
1944 When processing multiple files with a single command, to query the user
1945 you give @code{xargs} the following option.  When using this option, you
1946 might find it useful to control the number of files processed per
1947 invocation of the command (@pxref{Limiting Command Size}).
1949 @table @code
1950 @item --interactive
1951 @itemx -p
1952 Prompt the user about whether to run each command line and read a line
1953 from the terminal.  Only run the command line if the response starts
1954 with @samp{y} or @samp{Y}.  Implies @samp{-t}.
1955 @end table
1957 @node Delete Files
1958 @section Delete Files
1960 @deffn Action -delete
1961 Delete files or directories; true if removal succeeded.  If the
1962 removal failed, an error message is issued.
1964 The use of the @samp{-delete} action on the command line automatically
1965 turns on the @samp{-depth} option (@pxref{find Expressions}).
1966 @end deffn
1968 @node Adding Tests
1969 @section Adding Tests
1971 You can test for file attributes that none of the @code{find} builtin
1972 tests check.  To do this, use @code{xargs} to run a program that filters
1973 a list of files printed by @code{find}.  If possible, use @code{find}
1974 builtin tests to pare down the list, so the program run by @code{xargs}
1975 has less work to do.  The tests builtin to @code{find} will likely run
1976 faster than tests that other programs perform.
1978 For example, here is a way to print the names of all of the unstripped
1979 binaries in the @file{/usr/local} directory tree.  Builtin tests avoid
1980 running @code{file} on files that are not regular files or are not
1981 executable.
1983 @example
1984 find /usr/local -type f -perm +a=x | xargs file | 
1985   grep 'not stripped' | cut -d: -f1
1986 @end example
1988 @noindent
1989 The @code{cut} program removes everything after the file name from the
1990 output of @code{file}.
1992 @c Idea from Martin Weitzel.
1993 If you want to place a special test somewhere in the middle of a
1994 @code{find} expression, you can use @samp{-exec} to run a program that
1995 performs the test.  Because @samp{-exec} evaluates to the exit status of
1996 the executed program, you can write a program (which can be a shell
1997 script) that tests for a special attribute and make it exit with a true
1998 (zero) or false (non-zero) status.  It is a good idea to place such a
1999 special test @emph{after} the builtin tests, because it starts a new
2000 process which could be avoided if a builtin test evaluates to false.
2001 Use this method only when @code{xargs} is not flexible enough, because
2002 starting one or more new processes to test each file is slower than
2003 using @code{xargs} to start one process that tests many files.
2005 Here is a shell script called @code{unstripped} that checks whether its
2006 argument is an unstripped binary file:
2008 @example
2009 #! /bin/sh
2010 file $1 | grep 'not stripped' > /dev/null
2011 @end example
2013 This script relies on the fact that the shell exits with the status of
2014 the last program it executed, in this case @code{grep}.  @code{grep}
2015 exits with a true status if it found any matches, false if not.  Here is
2016 an example of using the script (assuming it is in your search path).  It
2017 lists the stripped executables in the file @file{sbins} and the
2018 unstripped ones in @file{ubins}.
2020 @example
2021 find /usr/local -type f -perm +a=x \
2022   \( -exec unstripped '@{@}' \; -fprint ubins -o -fprint sbins \)
2023 @end example
2025 @node Common Tasks, Databases, Actions, Top
2026 @chapter Common Tasks
2028 The sections that follow contain some extended examples that both give a
2029 good idea of the power of these programs, and show you how to solve
2030 common real-world problems.
2032 @menu
2033 * Viewing And Editing::
2034 * Archiving::
2035 * Cleaning Up::
2036 * Strange File Names::
2037 * Fixing Permissions::
2038 * Classifying Files::
2039 @end menu
2041 @node Viewing And Editing
2042 @section Viewing And Editing
2044 To view a list of files that meet certain criteria, simply run your file
2045 viewing program with the file names as arguments.  Shells substitute a
2046 command enclosed in backquotes with its output, so the whole command
2047 looks like this:
2049 @example
2050 less `find /usr/include -name '*.h' | xargs grep -l mode_t`
2051 @end example
2053 @noindent
2054 You can edit those files by giving an editor name instead of a file
2055 viewing program:
2057 @example
2058 emacs `find /usr/include -name '*.h' | xargs grep -l mode_t`
2059 @end example
2061 Because there is a limit to the length of any individual command line,
2062 there is a limit to the number of files that can be handled in this
2063 way.  We can get around this difficulty by using xargs like this:
2065 @example
2066 find /usr/include -name '*.h' | xargs grep -l mode_t > todo
2067 xargs --arg-file=todo emacs
2068 @end example
2070 Here, @code{xargs} will run @code{emacs} as many times as necessary to
2071 visit all of the files listed in the file @file{todo}.
2073 @node Archiving
2074 @section Archiving
2076 You can pass a list of files produced by @code{find} to a file archiving
2077 program.  GNU @code{tar} and @code{cpio} can both read lists of file
2078 names from the standard input---either delimited by nulls (the safe way)
2079 or by blanks (the lazy, risky default way).  To use null-delimited
2080 names, give them the @samp{--null} option.  You can store a file archive
2081 in a file, write it on a tape, or send it over a network to extract on
2082 another machine.
2084 One common use of @code{find} to archive files is to send a list of the
2085 files in a directory tree to @code{cpio}.  Use @samp{-depth} so if a
2086 directory does not have write permission for its owner, its contents can
2087 still be restored from the archive since the directory's permissions are
2088 restored after its contents.  Here is an example of doing this using
2089 @code{cpio}; you could use a more complex @code{find} expression to
2090 archive only certain files.
2092 @example
2093 find . -depth -print0 |
2094   cpio --create --null --format=crc --file=/dev/nrst0
2095 @end example
2097 You could restore that archive using this command:
2099 @example
2100 cpio --extract --null --make-dir --unconditional \
2101   --preserve --file=/dev/nrst0
2102 @end example
2104 Here are the commands to do the same things using @code{tar}:
2106 @example
2107 find . -depth -print0 |
2108   tar --create --null --files-from=- --file=/dev/nrst0
2110 tar --extract --null --preserve-perm --same-owner \
2111   --file=/dev/nrst0
2112 @end example
2114 @c Idea from Rick Sladkey.
2115 Here is an example of copying a directory from one machine to another:
2117 @example
2118 find . -depth -print0 | cpio -0o -Hnewc |
2119   rsh @var{other-machine} "cd `pwd` && cpio -i0dum"
2120 @end example
2122 @node Cleaning Up
2123 @section Cleaning Up
2125 @c Idea from Jim Meyering.
2126 This section gives examples of removing unwanted files in various situations.
2127 Here is a command to remove the CVS backup files created when an update
2128 requires a merge:
2130 @example
2131 find . -name '.#*' -print0 | xargs -0r rm -f
2132 @end example
2134 The command above works, but the following is safer:
2136 @example
2137 find . -name '.#*' -depth -delete
2138 @end example
2140 @c Idea from Franc,ois Pinard.
2141 You can run this command to clean out your clutter in @file{/tmp}.  You
2142 might place it in the file your shell runs when you log out
2143 (@file{.bash_logout}, @file{.logout}, or @file{.zlogout}, depending on
2144 which shell you use).
2146 @example
2147 find /tmp -depth -user "$LOGNAME" -type f -delete 
2148 @end example
2150 If your @code{find} command removes directories, you may find that 
2151 you get a spurious error message when @code{find} tries to recurse
2152 into a directory that has now been removed.  Using the @samp{-depth}
2153 option will normally resolve this problem.
2155 @c Idea from Noah Friedman.
2156 To remove old Emacs backup and auto-save files, you can use a command
2157 like the following.  It is especially important in this case to use
2158 null-terminated file names because Emacs packages like the VM mailer
2159 often create temporary file names with spaces in them, like @file{#reply
2160 to David J. MacKenzie<1>#}.
2162 @example
2163 find ~ \( -name '*~' -o -name '#*#' \) -print0 |
2164   xargs --no-run-if-empty --null rm -vf
2165 @end example
2167 Removing old files from @file{/tmp} is commonly done from @code{cron}:
2169 @c Idea from Kaveh Ghazi.
2170 @example
2171 find /tmp /var/tmp -not -type d -mtime +3 -delete
2172 find /tmp /var/tmp -depth -mindepth 1 -type d -empty -delete
2173 @end example
2175 The second @code{find} command above uses @samp{-depth} so it cleans out
2176 empty directories depth-first, hoping that the parents become empty and
2177 can be removed too.  It uses @samp{-mindepth} to avoid removing
2178 @file{/tmp} itself if it becomes totally empty.
2180 @node Strange File Names
2181 @section Strange File Names
2183 @c Idea from:
2184 @c From: tmatimar@isgtec.com (Ted Timar)
2185 @c Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
2186 @c Subject: Unix - Frequently Asked Questions (2/7) [Frequent posting]
2187 @c Subject: How do I remove a file with funny characters in the filename ?
2188 @c Date: Thu Mar 18 17:16:55 EST 1993
2189 @code{find} can help you remove or rename a file with strange characters
2190 in its name.  People are sometimes stymied by files whose names contain
2191 characters such as spaces, tabs, control characters, or characters with
2192 the high bit set.  The simplest way to remove such files is:
2194 @example
2195 rm -i @var{some*pattern*that*matches*the*problem*file}
2196 @end example
2198 @code{rm} asks you whether to remove each file matching the given
2199 pattern.  If you are using an old shell, this approach might not work if
2200 the file name contains a character with the high bit set; the shell may
2201 strip it off.  A more reliable way is:
2203 @example
2204 find . -maxdepth 1 @var{tests} -ok rm '@{@}' \;
2205 @end example
2207 @noindent
2208 where @var{tests} uniquely identify the file.  The @samp{-maxdepth 1}
2209 option prevents @code{find} from wasting time searching for the file in
2210 any subdirectories; if there are no subdirectories, you may omit it.  A
2211 good way to uniquely identify the problem file is to figure out its
2212 inode number; use
2214 @example
2215 ls -i
2216 @end example
2218 Suppose you have a file whose name contains control characters, and you
2219 have found that its inode number is 12345.  This command prompts you for
2220 whether to remove it:
2222 @example
2223 find . -maxdepth 1 -inum 12345 -ok rm -f '@{@}' \;
2224 @end example
2226 If you don't want to be asked, perhaps because the file name may contain
2227 a strange character sequence that will mess up your screen when printed,
2228 then use @samp{-exec} instead of @samp{-ok}.
2230 If you want to rename the file instead, you can use @code{mv} instead of
2231 @code{rm}:
2233 @example
2234 find . -maxdepth 1 -inum 12345 -ok mv '@{@}' @var{new-file-name} \;
2235 @end example
2237 @node Fixing Permissions
2238 @section Fixing Permissions
2240 Suppose you want to make sure that everyone can write to the directories in a
2241 certain directory tree.  Here is a way to find directories lacking either
2242 user or group write permission (or both), and fix their permissions:
2244 @example
2245 find . -type d -not -perm -ug=w | xargs chmod ug+w
2246 @end example
2248 @noindent
2249 You could also reverse the operations, if you want to make sure that
2250 directories do @emph{not} have world write permission.
2252 @node Classifying Files
2253 @section Classifying Files
2255 @c Idea from:
2256 @c From: martin@mwtech.UUCP (Martin Weitzel)
2257 @c Newsgroups: comp.unix.wizards,comp.unix.questions
2258 @c Subject: Advanced usage of 'find' (Re: Unix security automating script)
2259 @c Date: 22 Mar 90 15:05:19 GMT
2260 If you want to classify a set of files into several groups based on
2261 different criteria, you can use the comma operator to perform multiple
2262 independent tests on the files.  Here is an example:
2264 @example
2265 find / -type d \( -perm -o=w -fprint allwrite , \
2266   -perm -o=x -fprint allexec \)
2268 echo "Directories that can be written to by everyone:"
2269 cat allwrite
2270 echo ""
2271 echo "Directories with search permissions for everyone:"
2272 cat allexec
2273 @end example
2275 @code{find} has only to make one scan through the directory tree (which
2276 is one of the most time consuming parts of its work).
2278 @node Databases, File Permissions, Common Tasks, Top
2279 @chapter File Name Databases
2281 The file name databases used by @code{locate} contain lists of files
2282 that were in particular directory trees when the databases were last
2283 updated.  The file name of the default database is determined when
2284 @code{locate} and @code{updatedb} are configured and installed.  The
2285 frequency with which the databases are updated and the directories for
2286 which they contain entries depend on how often @code{updatedb} is run,
2287 and with which arguments.
2289 You can obtain some statistics about the databases by using
2290 @samp{locate --statistics}.
2292 @menu
2293 * Database Locations::
2294 * Database Formats::
2295 * Newline Handling::
2296 @end menu
2299 @node Database Locations
2300 @section Database Locations
2302 There can be multiple file name databases.  Users can select which
2303 databases @code{locate} searches using the @code{LOCATE_PATH}
2304 environment variable or a command line option.  The system
2305 administrator can choose the file name of the default database, the
2306 frequency with which the databases are updated, and the directories
2307 for which they contain entries.  File name databases are updated by
2308 running the @code{updatedb} program, typically nightly.
2310 In networked environments, it often makes sense to build a database at
2311 the root of each filesystem, containing the entries for that filesystem.
2312 @code{updatedb} is then run for each filesystem on the fileserver where
2313 that filesystem is on a local disk, to prevent thrashing the network.
2315 @xref{Invoking updatedb},
2316 for the description of the options to @code{updatedb}, which specify
2317 which directories would each database contain entries for.
2320 @node Database Formats
2321 @section Database Formats
2323 The file name databases contain lists of files that were in particular
2324 directory trees when the databases were last updated.  The file name
2325 database format changed starting with GNU @code{locate} version 4.0 to
2326 allow machines with different byte orderings to share the databases.  The
2327 new GNU @code{locate} can read both the old and new database formats.
2328 However, old versions of @code{locate} and @code{find} produce incorrect
2329 results if given a new-format database.
2331 If you run @samp{locate --statistics}, the resulting summary indicates
2332 the type of each locate database.  
2335 @menu
2336 * New Database Format::
2337 * Sample Database::
2338 * Old Database Format::
2339 @end menu
2341 @node New Database Format
2342 @subsection New Database Format
2344 @code{updatedb} runs a program called @code{frcode} to
2345 @dfn{front-compress} the list of file names, which reduces the database
2346 size by a factor of 4 to 5.  Front-compression (also known as
2347 incremental encoding) works as follows.
2349 The database entries are a sorted list (case-insensitively, for users'
2350 convenience).  Since the list is sorted, each entry is likely to share a
2351 prefix (initial string) with the previous entry.  Each database entry
2352 begins with an offset-differential count byte, which is the additional
2353 number of characters of prefix of the preceding entry to use beyond the
2354 number that the preceding entry is using of its predecessor.  (The
2355 counts can be negative.)  Following the count is a null-terminated ASCII
2356 remainder---the part of the name that follows the shared prefix.
2358 If the offset-differential count is larger than can be stored in a byte
2359 (+/-127), the byte has the value 0x80 and the count follows in a 2-byte
2360 word, with the high byte first (network byte order).
2362 Every database begins with a dummy entry for a file called
2363 @file{LOCATE02}, which @code{locate} checks for to ensure that the
2364 database file has the correct format; it ignores the entry in doing the
2365 search.
2367 Databases can not be concatenated together, even if the first (dummy)
2368 entry is trimmed from all but the first database.  This is because the
2369 offset-differential count in the first entry of the second and following
2370 databases will be wrong.
2372 In the output of @samp{locate --statistics}, the new database format
2373 is referred to as @samp{LOCATE02}.
2375 @node Sample Database
2376 @subsection Sample Database
2378 Sample input to @code{frcode}:
2379 @c with nulls changed to newlines:
2381 @example
2382 /usr/src
2383 /usr/src/cmd/aardvark.c
2384 /usr/src/cmd/armadillo.c
2385 /usr/tmp/zoo
2386 @end example
2388 Length of the longest prefix of the preceding entry to share:
2390 @example
2391 0 /usr/src
2392 8 /cmd/aardvark.c
2393 14 rmadillo.c
2394 5 tmp/zoo
2395 @end example
2397 Output from @code{frcode}, with trailing nulls changed to newlines
2398 and count bytes made printable:
2400 @example
2401 0 LOCATE02
2402 0 /usr/src
2403 8 /cmd/aardvark.c
2404 6 rmadillo.c
2405 -9 tmp/zoo
2406 @end example
2408 (6 = 14 - 8, and -9 = 5 - 14)
2410 @node Old Database Format
2411 @subsection Old Database Format
2413 The old database format is used by Unix @code{locate} and @code{find}
2414 programs and earlier releases of the GNU ones.  @code{updatedb} produces
2415 this format if given the @samp{--old-format} option.
2417 @code{updatedb} runs programs called @code{bigram} and @code{code} to
2418 produce old-format databases.  The old format differs from the new one
2419 in the following ways.  Instead of each entry starting with an
2420 offset-differential count byte and ending with a null, byte values from
2421 0 through 28 indicate offset-differential counts from -14 through 14.
2422 The byte value indicating that a long offset-differential count follows
2423 is 0x1e (30), not 0x80.  The long counts are stored in host byte order,
2424 which is not necessarily network byte order, and host integer word size,
2425 which is usually 4 bytes.  They also represent a count 14 less than
2426 their value.  The database lines have no termination byte; the start of
2427 the next line is indicated by its first byte having a value <= 30.
2429 In addition, instead of starting with a dummy entry, the old database
2430 format starts with a 256 byte table containing the 128 most common
2431 bigrams in the file list.  A bigram is a pair of adjacent bytes.  Bytes
2432 in the database that have the high bit set are indexes (with the high
2433 bit cleared) into the bigram table.  The bigram and offset-differential
2434 count coding makes these databases 20-25% smaller than the new format,
2435 but makes them not 8-bit clean.  Any byte in a file name that is in the
2436 ranges used for the special codes is replaced in the database by a
2437 question mark, which not coincidentally is the shell wildcard to match a
2438 single character.
2440 The old format therefore can not faithfully store entries with non-ASCII
2441 characters. It therefore should not be used in internationalized
2442 environments.
2444 The output of @samp{locate --statistics} will give an incorrect count
2445 of the number of filenames containing newlines or high-bit characters
2446 for old-format databases.
2448 @node Newline Handling
2449 @section Newline Handling
2451 Within the database, filenames are terminated with a null character.
2452 This is the case for both the old and the new format.  
2454 When the new database format is being used, the compression technique
2455 used to generate the database though relies on the ability to sort the
2456 list of files before they are presented to @code{frcode}.
2458 If the system's sort command allows its input list of files to be
2459 separated with null characters via the @samp{-z} option, this option
2460 is used and therefore @code{updatedb} and @code{locate} will both
2461 correctly handle filenames containing newlines.  If the @code{sort}
2462 command lacks support for this, the list of files is delimited with
2463 the newline character, meaning that parts of filenames containing
2464 newlines will be incorrectly sorted.  This can result in both
2465 incorrect matches and incorrect failures to match.
2467 On the other hand, if you are using the old database format, filenames
2468 with embedded newlines are not correctly handled.  There is no
2469 technical limitation which enforces this, it's just that the
2470 @code{bigram} program has no been updated to support lists of
2471 filenames separated by nulls.
2473 So, if you are using the new database format (this is the default) and
2474 your system uses GNU @code{find}, newlines will be correctly handled
2475 at all times.  Otherwise, newlines may not be correctly handled.
2477 @node File Permissions, Reference, Databases, Top
2478 @chapter File Permissions
2480 @include perm.texi
2482 @node Reference, Security Considerations, File Permissions, Top
2483 @chapter Reference
2485 Below are summaries of the command line syntax for the programs
2486 discussed in this manual.
2488 @menu
2489 * Invoking find::
2490 * Invoking locate::
2491 * Invoking updatedb::
2492 * Invoking xargs::
2493 @end menu
2495 @node Invoking find, Invoking locate, , Reference
2496 @section Invoking @code{find}
2498 @example
2499 find @r{[-H] [-L] [-P]} @r{[}@var{file}@dots{}@r{]} @r{[}@var{expression}@r{]}
2500 @end example
2502 @code{find} searches the directory tree rooted at each file name
2503 @var{file} by evaluating the @var{expression} on each file it finds in
2504 the tree.
2506 The options @samp{-H}, @samp{-L} or @samp{-P} may be specified at the
2507 start of the command line (if none of these is specified, @samp{-P} is
2508 assumed).  The arguments after these are a list of files or
2509 directories that should be searched.
2511 This list of files to search is followed by a list of expressions
2512 describing the files we wish to search for.  The first part of the
2513 expression is recognised by the fact that it begins with @samp{-},
2514 @samp{(}, @samp{)}, @samp{,}, or @samp{!}.  Any arguments after it are
2515 the rest of the expression.  If no paths are given, the current
2516 directory is used.  If no expression is given, the expression
2517 @samp{-print} is used.
2519 @code{find} exits with status 0 if all files are processed successfully,
2520 greater than 0 if errors occur.
2522 Three options can precede the list of path names.  They determine the
2523 way that symbolic links are handled.
2525 @table @code
2526 @item -P
2527 Never follow symbolic links (this is the default), except in the case
2528 of the @samp{-xtype} predicate.
2529 @item -L
2530 Always follow symbolic links, except in the case of the @samp{-xtype}
2531 predicate.
2532 @item -H
2533 Follow symbolic links specified in the list of paths to search, or
2534 which are otherwise specified on the command line.
2535 @end table
2537 If @code{find} would follow a symbolic link, but cannot for any reason
2538 (for example, because it has insufficient permissions or the link is
2539 broken), it falls back on using the properties of the symbolic link
2540 itself.  @ref{Symbolic Links} for a more complete description of how
2541 symbolic links are handled.
2543 @xref{Primary Index}, for a summary of all of the tests, actions, and
2544 options that the expression can contain.  If the expression is
2545 missing, @samp{-print} is assumed.
2549 @code{find} also recognizes two options for administrative use:
2551 @table @code
2552 @item --help
2553 Print a summary of the command-line argument format and exit.
2554 @item --version
2555 Print the version number of @code{find} and exit.
2556 @end table
2559 @menu
2560 * Warning Messages::
2561 @end menu
2564 @node Warning Messages,,, Invoking find
2565 @subsection Warning Messages
2567 If there is an error on the @code{find} command line, an error message
2568 is normally issued.  However, there are some usages that are
2569 inadvisable but which @code{find} should still accept.  Under these
2570 circumstances, @code{find} may issue a warning message.  By default,
2571 warnings are enabled only if @code{find} is being run interactively
2572 (specifically, if the standard input is a terminal).  Warning messages
2573 can be controlled explicitly by the use of options on the command
2574 line:
2576 @table @code
2577 @item -warn
2578 Issue warning messages where appropriate.
2579 @item -nowarn
2580 Do not issue warning messages.
2581 @end table
2583 These options take effect at the point on the command line where they
2584 are specified.  Therefore if you specify @samp{-nowarn} at the end of
2585 the command line, you will not see warning messages for any problems
2586 occurring before that.  The warning messages affected by the above
2587 options are triggered by:
2589 @itemize @minus
2590 @item
2591 Use of the @samp{-d} option which is deprecated; please use
2592 @samp{-depth} instead, since the latter is POSIX-compliant.
2593 @item
2594 Use of the @samp{-ipath} option which is deprecated; please use
2595 @samp{-iwholename} instead.
2596 @item 
2597 Specifying an option (for example @samp{-mindepth}) after a non-option
2598 (for example @samp{-type} or @samp{-print}) on the command line.
2599 @end itemize
2602 The default behaviour above is designed to work in that way so that
2603 existing shell scripts which use such constructs don't generate
2604 spurious errors, but people will be made aware of the problem.
2606 Some warning messages are issued for less common or more serious
2607 problems, and so cannot be turned off:
2609 @itemize @minus
2610 @item
2611 Use of an unrecognised backslash escape sequence with @samp{-fprintf}
2612 @item
2613 Use of an unrecognised formatting directive with @samp{-fprintf}
2614 @end itemize
2616 @node Invoking locate, Invoking updatedb, Invoking find, Reference
2617 @section Invoking @code{locate}
2619 @example
2620 locate @r{[}@var{option}@dots{}@r{]} @var{pattern}@dots{}
2621 @end example
2623 @table @code
2624 @item --database=@var{path}
2625 @itemx -d @var{path}
2626 Instead of searching the default file name database, search the file
2627 name databases in @var{path}, which is a colon-separated list of
2628 database file names.  You can also use the environment variable
2629 @code{LOCATE_PATH} to set the list of database files to search.  The
2630 option overrides the environment variable if both are used.
2632 @item --existing
2633 @itemx -e
2634 Only print out such names which currently exist (instead of such names
2635 which existed when the database was created).
2636 Note that this may slow down the program a lot, if there are many matches
2637 in the database.
2639 @item --ignore-case
2640 @itemx -i
2641 Ignore case distinctions in both the pattern and the file names.
2643 @item --null
2644 @itemx -0
2645 Results are separated with the ASCII NUL character rather than the
2646 newline character.  To get the full benefit of the use of this option,
2647 use the new locate database format (that is the default anyway).
2649 @item --count
2650 @itemx -c
2651 Just print the number of results, not the results themselves.
2653 @item --limit=N
2654 @itemx -l N
2655 Limit the number of results printed to N.  If you use the
2656 @samp{--count} option, the value printed will never be larger than
2657 this limit.
2659 @item --wholename
2660 The specified pattern is matched against the whole name of the file in
2661 the locate database.  If the pattern contains metacharacters, it must
2662 match exactly.  If not, it must match part of the whole file name.
2663 This is the default behaviour.
2665 @item --basename
2666 @itemx -b
2667 The specified pattern is matched against just the last component of
2668 the name of the file in the locate database.  This last component is
2669 also called the ``base name''.  For example, the base name of
2670 @file{/tmp/mystuff/foo.old.c} is @file{foo.old.c}.  If the pattern
2671 contains metacharacters, it must match exactly.  If not, it must match
2672 part of the whole file name.
2674 @item --statistics
2675 @itemx -S
2676 Print some summary information for each locate database.  No search is
2677 performed. 
2679 @item --help
2680 Print a summary of the options to @code{locate} and exit.
2682 @item --version
2683 Print the version number of @code{locate} and exit.
2684 @end table
2686 @node Invoking updatedb, Invoking xargs, Invoking locate, Reference
2687 @section Invoking @code{updatedb}
2689 @example
2690 updatedb @r{[}@var{option}@dots{}@r{]}
2691 @end example
2693 @table @code
2694 @item --findoptions='@var{OPTION}@dots{}'
2695 Global options to pass on to @code{find}.
2696 The environment variable @code{FINDOPTIONS} also sets this value.
2697 Default is none.
2699 @item --localpaths='@var{path}@dots{}'
2700 Non-network directories to put in the database.
2701 Default is @file{/}.
2703 @item --netpaths='@var{path}@dots{}'
2704 Network (NFS, AFS, RFS, etc.) directories to put in the database.
2705 The environment variable @code{NETPATHS} also sets this value.
2706 Default is none.
2708 @item --prunepaths='@var{path}@dots{}'
2709 Directories to omit from the database, which would otherwise be included.
2710 The environment variable @code{PRUNEPATHS} also sets this value.
2711 Default is @file{/tmp /usr/tmp /var/tmp /afs}.
2713 @item --prunefs='@var{path}@dots{}'
2714 File systems to omit from the database, which would otherwise be included.
2715 Note that files are pruned when a file system is reached;
2716 Any file system mounted under an undesired file system will be
2717 ignored.
2718 The environment variable @code{PRUNEFS} also sets this value.
2719 Default is @file{nfs NFS proc}.
2721 @item --output=@var{dbfile}
2722 The database file to build.
2723 Default is system-dependent, but typically @file{/usr/local/var/locatedb}.
2725 @item --localuser=@var{user}
2726 The user to search the non-network directories as, using @code{su}.
2727 Default is to search the non-network directories as the current user.
2728 You can also use the environment variable @code{LOCALUSER} to set this user.
2730 @item --netuser=@var{user}
2731 The user to search network directories as, using @code{su}.
2732 Default is @code{daemon}.
2733 You can also use the environment variable @code{NETUSER} to set this user.
2735 @item --old-format
2736 Generate a locate database in the old format, for compatibility with
2737 versions of @code{locate} other than GNU @code{locate}.  Using this
2738 option means that @code{locate} will not be able to properly handle
2739 non-ASCII characters in filenames (that is, filenames containing
2740 characters which have the eighth bit set, such as many of the
2741 characters from the ISO-8859-1 character set).
2742 @item --help
2743 Print a summary of the command-line argument format and exit.
2744 @item --version
2745 Print the version number of @code{updatedb} and exit.
2746 @end table
2748 @node Invoking xargs, ,  Invoking updatedb, Reference
2749 @section Invoking @code{xargs}
2751 @example
2752 xargs @r{[}@var{option}@dots{}@r{]} @r{[}@var{command} @r{[}@var{initial-arguments}@r{]}@r{]}
2753 @end example
2755 @code{xargs} exits with the following status:
2757 @table @asis
2758 @item 0
2759 if it succeeds
2760 @item 123
2761 if any invocation of the command exited with status 1-125
2762 @item 124
2763 if the command exited with status 255
2764 @item 125
2765 if the command is killed by a signal
2766 @item 126
2767 if the command cannot be run
2768 @item 127
2769 if the command is not found
2770 @item 1
2771 if some other error occurred.
2772 @end table
2774 @table @code
2775 @item --arg-file@r{=@var{inputfile}}
2776 @itemx -a @r{=@var{inputfile}}
2777 Read names from the file @var{inputfile} instead of standard input.
2779 @item --null
2780 @itemx -0
2781 Input filenames are terminated by a null character instead of by
2782 whitespace, and the quotes and backslash are not special (every
2783 character is taken literally).  Disables the end of file string, which
2784 is treated like any other argument.
2786 @item --eof@r{[}=@var{eof-str}@r{]}
2787 @itemx -e@r{[}@var{eof-str}@r{]}
2788 Set the end of file string to @var{eof-str}.  If the end of file string
2789 occurs as a line of input, the rest of the input is ignored.  If
2790 @var{eof-str} is omitted, there is no end of file string.  If this
2791 option is not given, the end of file string defaults to @samp{_}.
2793 @item --help
2794 Print a summary of the options to @code{xargs} and exit.
2796 @item --replace@r{[}=@var{replace-str}@r{]}
2797 @itemx -i@r{[}@var{replace-str}@r{]}
2798 Replace occurrences of @var{replace-str} in the initial arguments with
2799 names read from standard input.  Also, unquoted blanks do not
2800 terminate arguments; instead, the input is split at newlines only.
2801 If @var{replace-str} is omitted, it defaults to @samp{@{@}}
2802 (like for @samp{find -exec}).  Implies @samp{-x} and @samp{-l 1}.
2804 @item --max-lines@r{[}=@var{max-lines}@r{]}
2805 @itemx -l@r{[}@var{max-lines}@r{]}
2806 Use at most @var{max-lines} nonblank input lines per command line;
2807 @var{max-lines} defaults to 1 if omitted.  Trailing blanks cause an
2808 input line to be logically continued on the next input line, for the
2809 purpose of counting the lines.  Implies @samp{-x}.
2811 @item --max-args=@var{max-args}
2812 @itemx -n @var{max-args}
2813 Use at most @var{max-args} arguments per command line.  Fewer than
2814 @var{max-args} arguments will be used if the size (see the @samp{-s}
2815 option) is exceeded, unless the @samp{-x} option is given, in which case
2816 @code{xargs} will exit.
2818 @item --interactive
2819 @itemx -p
2820 Prompt the user about whether to run each command line and read a line
2821 from the terminal.  Only run the command line if the response starts
2822 with @samp{y} or @samp{Y}.  Implies @samp{-t}.
2824 @item --no-run-if-empty
2825 @itemx -r
2826 If the standard input does not contain any nonblanks, do not run the
2827 command.  By default, the command is run once even if there is no input.
2829 @item --max-chars=@var{max-chars}
2830 @itemx -s @var{max-chars}
2831 Use at most @var{max-chars} characters per command line, including the
2832 command and initial arguments and the terminating nulls at the ends of
2833 the argument strings.
2835 @item --verbose
2836 @itemx -t
2837 Print the command line on the standard error output before executing
2840 @item --version
2841 Print the version number of @code{xargs} and exit.
2843 @item --exit
2844 @itemx -x
2845 Exit if the size (see the @samp{-s} option) is exceeded.
2848 @item --max-procs=@var{max-procs}
2849 @itemx -P @var{max-procs}
2850 Run up to @var{max-procs} processes at a time; the default is 1.  If
2851 @var{max-procs} is 0, @code{xargs} will run as many processes as
2852 possible at a time.
2853 @end table
2855 @node Security Considerations, Error Messages, Reference, Top
2856 @chapter Security Considerations
2858 Security considerations are important if you are using @code{find} or
2859 @code{xargs} to search for or process files that don't belong to you
2860 or over which other people have control.  Security considerations
2861 relating to @code{locate} may also apply if you have files which you
2862 may not want others to see.   
2864 In general, the most severe forms of security problems affecting
2865 @code{find} and related programs are where third parties can bring
2866 about a situation where those programs allow them to do something
2867 they would normally not be able to do.  This is called @emph{privilege
2868 elevation}.  This might include deleting files they would not normally
2869 be able to delete.  It is also common for the system to periodically
2870 invoke @code{find} for housekeeping purposes.  These invocations of
2871 @code{find} are particularly problematic from a security point of view
2872 as these are often invoked by the superuser and search the whole file
2873 system hierarchy.  The severity of any associated problem depends on
2874 what the system is going to do with the output of @code{find}.
2876 @menu
2877 * Levels of Risk::      What is your level of exposure to security problems?
2878 * Security Considerations for find::  Security problems with find
2879 * Security Considerations for xargs:: Security problems with xargs
2880 * Security Considerations for locate:: Security problems with locate
2881 * Security Summary:: That was all very complex, what does it boil down to?
2882 @end menu
2885 @node Levels of Risk
2886 @section Levels of Risk
2888 There are some security risks inherent in the use of @code{find},
2889 @code{xargs} and (to a lesser extent) @code{locate}.  The severity of
2890 these risks depends on what sort of system you are using:
2892 @table @strong
2893 @item High risk
2894 Multi-user systems where you do not control (or trust) the other
2895 users, and on which you execute @code{find}, including areas where
2896 those other users can manipulate the filesystem (for example beneath
2897 @file{/home} or @file{/tmp}).
2899 @item Medium Risk
2900 Systems where the actions of other users can create filenames chosen
2901 by them, but to which they don't have access while @code{find} is
2902 being run.  This access might include leaving programs running (shell
2903 background jobs, @code{at} or @code{cron} tasks, for example).  On
2904 these sorts of systems, carefully written commands (avoiding use of
2905 @samp{-print} for example) should not expose you to a high degree of
2906 risk.  Most systems fall into this category.
2908 @item Low Risk
2909 Systems to which untrusted parties do not have access, cannot create
2910 filenames of their own choice (even remotely) and which contain no
2911 security flaws which might enable an untrusted third party to gain
2912 access.  Most systems do not fall into this category because there are
2913 many ways in which external parties can affect the names of files that
2914 are created on your system.  The system on which I am writing this for
2915 example automatically downloads software updates from the Internet;
2916 the names of the files in which these updates exist are chosen by
2917 third parties@footnote{Of course, I trust these parties to a large
2918 extent anyway, because I install software provided by them; I choose
2919 to trust them in this way, and that's a deliberate choice}.
2920 @end table
2922 In the discussion above, ``risk'' denotes the likelihood that someone
2923 can cause @code{find}, @code{xargs}, @code{locate} or some other
2924 program which is controlled by them to do something you did not
2925 intend.  The levels of risk suggested do not take any account of the
2926 consequences of this sort of event.  That is, if you operate a ``low
2927 risk'' type system, but the consequences of a security problem are
2928 disastrous, then you should still give serious thought to all the
2929 possible security problems, many of which of course will not be
2930 discussed here -- this section of the manual is intended to be
2931 informative but not comprehensive or exhaustive.   
2933 If you are responsible for the operation of a system where the
2934 consequences of a security problem could be very important, you should
2935 do two things:-
2937 @enumerate
2938 @item Define a security policy which defines who is allowed to do what
2939 on your system
2940 @item Seek competent advice on how to enforce your policy, detect
2941 breaches of that policy, and take account of any potential problems
2942 that might fall outside the scope of your policy
2943 @end enumerate
2946 @node Security Considerations for find
2947 @section Security Considerations for find
2950 Some of the actions @code{find} might take have a direct effect;
2951 these include @code{-exec} and @code{-delete}.  However, it is also
2952 common to use @code{-print} explicitly or implicitly, and so if
2953 @code{find} produces the wrong list of filenames, that can also be a
2954 security problem; consider the case for example where @code{find} is
2955 producing a list of files to be deleted.
2957 We normally assume that the @code{find} command line expresses the
2958 file selection criteria and actions that the user had in mind -- that
2959 is, the command line is ``trusted'' data.  
2961 From a security analysis point of view, the output of @code{find}
2962 should be correct; that is, the output should contain only the names
2963 of those files which meet the user's criteria specified on the command
2964 line.  This applies for the @code{-exec} and @code{-delete} actions;
2965 one can consider these to be part of the output.
2967 On the other hand, the contents of the filesystem can be manipulated
2968 by other people, and hence we regard this as ``untrusted'' data.  This
2969 implies that the @code{find} command line is a filter which converts
2970 the untrusted contents of the filesystem into a correct list of output
2971 files.   
2973 The filesystem will in general change while @code{find} is searching
2974 it; in fact, most of the potential security problems with @code{find}
2975 relate to this issue in some way.
2977 Race conditions are a general class of security problem where the
2978 relative ordering of actions taken by @code{find} (for example) and
2979 something else are important@footnote{This is more or less the
2980 definition of the term ``race condition''} .  
2982 Typically, an attacker might move or rename files or directories in
2983 the hope that an action might be taken against a a file which was not
2984 normally intended to be affected.  Alternatively, this sort of attack
2985 might be intended to persuade @code{find} to search part of the
2986 filesystem which would not normally be included in the search
2987 (defeating the @code{-prune} action for example).  
2989 @subsection Changing the Current Working Directory
2990 As find searches the file system, it finds subdirectories and then
2991 searches within them by changing its working directory.    First,
2992 @code{find} notices a subdirectory.  It then decides if that
2993 subdirectory meets the criteria for being searched; that is, any
2994 @samp{-xdev} or @samp{-prune} expressions are taken into account.  The
2995 @code{find} program will then change working directory using the
2996 @code{chdir()} system call and proceed to search the directory.  
2998 A race condition attack might take the form that once the checks
2999 relevant to @samp{-xdev} and @samp{-prune} have been done, an attacker
3000 might rename the directory that was being considered, and put in its
3001 place a symbolic link that actually points somewhere else.  The
3002 @code{find} command would then issue the @code{chdir()} system call,
3003 changing its working directory to the destination of the symbolic link
3004 (@code{chdir()} will always dereference symbolic links).  This
3005 manipulation leaves @code{find} with a working directory chosen by an
3006 attacker, bypassing any protection apparently provided by @samp{-xdev}
3007 and @samp{-prune}, and any protection provided by being able to
3008 @emph{not} list particular directories on the @code{find} command
3009 line.  This form of attack is particularly problematic if the attacker
3010 can predict when the @code{find} command will be run, as is the case
3011 with @code{cron} tasks for example.  
3013 GNU @code{find} has specific safeguards to prevent this general class
3014 of problem.  Each time @code{find} changes directory, it examines the
3015 directory it is about to move to, issues the @code{chdir()} system
3016 call, and then checks that it has ended up in the subdirectory it
3017 expected.  If not, an error message is issued and @code{find} exits
3018 immediately.  This prevents filesystem manipulation attacks from
3019 persuading @code{find} to search parts of the filesystem it did not
3020 intend.
3022 Where an automounter is in use, it can be the case that the use of the
3023 @code{chdir()} system call can itself cause a new filesystem to be
3024 mounted at that point.  This will cause @code{find}'s security check
3025 to fail.  However, this does not normally represent a security problem
3026 (since the automounter configuration is normally set up by the system
3027 administrator).  Therefore, if the @code{chdir()} sanity check fails,
3028 @code{find} will check to see if a new filesystem has been mounted at
3029 the current directory; if so, @code{find} will issue a warning message
3030 and continue.  
3033 @subsection Race Conditions with -exec
3035 The @samp{-exec} action causes another program to be run.  It is
3036 passed the name of the file which is being considered at the time.
3037 The invoked program will then - normally - perform some action on that
3038 file.  Once again, there is a race condition which can be exploited
3039 here.  We shall take as a specific example the command
3041 @example 
3042 find /tmp -path /tmp/umsp/passwd -exec /bin/rm
3043 @end example
3045 In this simple example, we are identifying just one file to be deleted
3046 and invoking @code{/bin/rm} to delete it.  A problem exists because
3047 there is a time gap between the point where @code{find} decides that
3048 it needs to process the @samp{-exec} action and the point where the
3049 @code{/bin/rm} command actually issues the @code{unlink()} system
3050 call.  Within this time period, an attacker can rename the
3051 @file{/tmp/umsp} directory, replacing it with a symbolic link to
3052 @file{/etc}.   There is no way for @code{/bin/rm} to determine that it
3053 is working on the same file that @code{find} had in mind.   Once the
3054 symbolic link is in place, the attacker has persuaded @code{find} to
3055 cause the deletion of the @file{/etc/passwd} file, which is not the
3056 effect intended by the command which was actually invoked.  
3058 One possible defence against this type of attack is to modify the
3059 behaviour of @samp{-exec} so that the @code{/bin/rm} command is run
3060 with the argument @file{./passwd} and a suitable choice of working
3061 directory.  This would allow the normal sanity check that @code{find}
3062 performs to protect against this form of attack too.  Unfortunately,
3063 this strategy cannot be used as the POSIX standard specifies that the
3064 current working directory for commands invoked via @samp{-exec} must
3065 be the same as the current working directory from which @code{find}
3066 was invoked.   This means that the @samp{-exec} action is inherently
3067 insecure and can't be fixed.   
3069 GNU @code{find} implements a more secure variant of the @samp{-exec}
3070 action, @samp{-execdir}.  The @samp{-execdir} action
3071 ensures that it is not necessary to dereference subdirectories to
3072 process target files.  The current directory used to invoke programs
3073 is the same as the directory in which the file to be processed exists
3074 (@file{/tmp/umsp} in our example, and only the basename of the file to
3075 be processed is passed to the invoked command, with a @samp{./}
3076 prepended (giving @file{./passwd} in our example).
3079 @subsection Race Conditions with -print and -print0
3081 The @samp{-print} and @samp{-print0} actions can be used to produce a
3082 list of files matching some criteria, which can then be used with some
3083 other command, perhaps with @code{xargs}.   Unfortunately, this means
3084 that there is an unavoidable time gap between @code{find} deciding
3085 that one or more files meet its criteria and the relevant command
3086 being executed.  For this reason, the @samp{-print} and @samp{-print0}
3087 actions are just as insecure as @samp{-exec}.
3089 In fact, since the construction 
3091 @example
3092 find ....   -print | xargs ....
3093 @end example
3095 does not cope correctly with newlines or other ``white space'' in
3096 filenames, and copes poorly with filenames containing quotes, the
3097 @samp{-print} action is less secure even than @samp{-print0}.
3100 @comment  node-name,  next,  previous,  up
3101 @comment @node Security Considerations for xargs
3102 @node Security Considerations for xargs
3103 @section Security Considerations for @code{xargs}
3105 The description of the race conditions affecting the @samp{-print}
3106 action of @code{find} shows that @code{xargs} cannot be secure if it
3107 is possible for an attacker to modify a filesystem after @code{find}
3108 has started but before @code{xargs} has completed all its actions.
3110 However, there are other security issues that exist even if it is not
3111 possible for an attacker to have access to the filesystem in real
3112 time.  Firstly, if it is possible for an attacker to create files with
3113 names of their own choice on the filesystem, then @code{xargs} is
3114 insecure unless the @samp{-0} option is used.  If a file with the name
3115 @file{/home/someuser/foo/bar\n/etc/passwd} exists (assume that
3116 @samp{\n} stands for a newline character), then @code{find ... -print}
3117 can be persuaded to print three separate lines:
3119 @example
3120 /home/someuser/foo/bar
3122 /etc/passwd
3123 @end example
3125 If it finds a blank line in the input, @code{xargs} will ignore it.
3126 Therefore, if some action is to be taken on the basis of this list of
3127 files, the @file{/etc/passwd} file would be included even if this was
3128 not the intent of the person running find.  There are circumstances in
3129 which an attacker can use this to their advantage.  The same
3130 consideration applies to filenames containing ordinary spaces rather
3131 than newlines, except that of course the list of filenames will no
3132 longer contain an ``extra'' newline.
3134 This problem is an unavoidable consequence of the default behaviour of
3135 the @code{xargs} command, which is specified by the POSIX standard.
3136 The only ways to avoid this problem are either to avoid all use of
3137 @code{xargs} in favour for example of @samp{find -exec} or (where
3138 available) @samp{find -execdir}, or to use the @samp{-0} option, which
3139 ensures that @code{xargs} considers filenames to be separated by ASCII
3140 NUL characters rather than whitespace.   However, useful though this
3141 option is, the POSIX standard does not make it mandatory.
3143 @comment  node-name,  next,  previous,  up
3144 @node Security Considerations for locate
3145 @section Security Considerations for @code{locate}
3147 It is fairly unusual for the output of @code{locate} to be fed into
3148 another command.  However, if this were to be done, this would raise
3149 the same set of security issues as the use of @samp{find ... -print}.
3150 Although the problems relating to whitespace in filenames can be
3151 resolved by using @code{locate}'s @samp{-0} option, this still leaves
3152 the race condition problems associated with @samp{find ... -print0}.
3153 There is no way to avoid these problems in the case of @code{locate}.
3155 @node Security Summary
3156 @section Summary
3158 Where untrusted parties can create files on the system, or affect the
3159 names of files that are created, all uses for @code{find},
3160 @code{locate} and @code{xargs} have known security problems except the
3161 following:
3163 @table @asis
3164 @item Informational use only
3165 Uses where the programs are used to prepare lists of filenames upon which no further action will ever be taken.
3167 @item -delete 
3168 Use of the @samp{-delete} action to delete files which meet
3169 specified criteria
3171 @item -execdir 
3172 Use of the @samp{-execdir} action where the @env{PATH}
3173 environment variable contains directories which contain only trusted
3174 programs. 
3175 @end table
3177 @comment  node-name,  next,  previous,  up
3178 @node Error Messages, Primary Index, Security Considerations, Top
3179 @chapter Error Messages
3181 This section describes some of the error messages you might get from
3182 @code{find}, @code{xargs}, or @code{locate}, explains them and in some
3183 cases provides advice as to what you should do about this.
3185 This manual is written in English.  The GNU findutils software
3186 features translated error messages for many languages.  For this
3187 reason where possible we try to make the error messages produced by
3188 the programs self-explanatory.  This approach avoids asking people to
3189 figure out which English-language error message the test they actually
3190 saw might correspond to. Error messages which are self-explanatory
3191 will not normally be described or discussed in this document.  For
3192 those messages which are discussed in this document, only the
3193 English-language version of the message will be listed.
3195 @menu
3196 * Error Messages From find::
3197 * Error Messages From xargs::
3198 * Error Messages From locate::
3199 * Error Messages From updatedb::
3200 @end menu
3202 @node Error Messages From find, Error Messages From xargs, , Error Messages
3203 @section Error Messages From find
3205 @table @samp
3206 @item invalid predicate `-foo'
3207 This means that the @code{find} command line included something that
3208 started with a dash or other special character.  The @code{find}
3209 program tried to interpret this as a test, action or option, but
3210 didn't recognise it.  If you intended it to be a test, check what you
3211 specified against the documentation.  If, on the other hand, the
3212 string is the name of a file which has been expanded from a wildcard
3213 (for example because you have a @samp{*} on the command line),
3214 consider using @samp{./*} or just @samp{.} instead.
3216 @item unexpected extra predicate
3217 This usually happens if you have an extra bracket on the command line
3218 (for example @samp{find . -print \)}).
3220 @item Warning: filesystem /path/foo has recently been mounted
3221 @itemx Warning: filesystem /path/foo has recently been unmounted
3222 These messages might appear when @code{find} moves into a directory
3223 and finds that the device number and inode are different to what it
3224 expected them to be.  If the directory @code{find} has moved into is
3225 on an NFS filesystem, it will not issue this message, because
3226 @code{automount} frequently mounts new filesystems on directories as
3227 you move into them (that is how it knows you want to use the
3228 filesystem).  So, if you do see this message, be wary --
3229 @code{automount} may not have been responsible.  Consider the
3230 possibility that someone else is manipulating the filesystem while
3231 @code{find} is running.  Some people might do this in order to mislead
3232 @code{find} or persuade it to look at one set of files when it thought
3233 it was looking at another set.
3235 @item /path/foo changed during execution of find (old device number 12345, new device number 6789, filesystem type is <whatever>) [ref XXX]
3236 This message is issued when @code{find} changes directory and ends up
3237 somewhere it didn't expect to be.  This happens in one of two
3238 circumstances.  Firstly this happens when ``automount'' does its thing
3239 on a system where @code{find} doesn't know how to determine what the
3240 current set of mounted filesystems is@footnote{To do this, @code{find}
3241 requires to be able to use @code{getmntent()} - check the
3242 @file{config.h} file for HAVE_GETMNTENT, which should be #defined to
3243 1.  If HAVE_GETMNTENT is not set, consider submitting a problem report
3244 to @email{bug-findutils@@gnu.org}, because @code{find} needs to be
3245 able to figure out how to enumerate the mounted devices on your
3246 system}.
3248 Secondly, this can happen when the device number of a directory
3249 appears to change during a change of current directory, but
3250 @code{find} is moving up the filesystem hierarchy rather than down it.
3251 In order to prevent @code{find} wandering off into some unexpected
3252 part of the filesystem, we stop it at this point.
3254 @item Don't know how to use getmntent() to read `/etc/mtab'.  This is a bug.
3255 This message is issued when a problem similar to the above occurs on a
3256 system where @code{find} doesn't know how to figure out the current
3257 list of mount points.  Ask for help on @email{bug-findutils@@gnu.org}.
3259 @item /path/foo/bar changed during execution of find (old inode number 12345, new inode number 67893, filesystem type is <whatever>) [ref XXX]"),
3260 This message is issued when @code{find} changes directory and
3261 discovers that the inode number of that directory once it's got there
3262 is different to the inode number that it obtained when it examined the
3263 directory some time previously.  This normally means that while
3264 @code{find} has been deep in a directory hierarchy doing something
3265 time consuming, somebody has moved the one of the parent directories
3266 to another location in the same filesystem.  This may have been done
3267 maliciously, or may not.  In any case, @code{find} stops at this point
3268 in order to avoid traversing parts of the filesystem that it wasn't
3269 intended to.  You can use @code{ls -li} or @code{find /path -inum
3270 12345 -o -inum 67893} to find out more about what has happened.
3272 @item sanity check of the fnmatch() library function failed.
3273 Please submit a bug report.  You may well be asked questions about
3274 your system, and if you compiled the @code{findutils} code yourself,
3275 you should keep your copy of the build tree around.  The likely
3276 explanation is that your system has a buggy implementation of
3277 @code{fnmatch} that looks enough like the GNU version to fool
3278 @code{configure}, but which doesn't work properly.
3280 @item cannot fork
3281 This normally happens if you use the @code{-exec} action or a
3282 something similar (@code{-ok} and so forth) but the system has run out
3283 of free process slots.  This is either because the system is very busy
3284 and the system has reached its maximum process limit, or because you
3285 have a resource limit in place and you've reached it.  Check the
3286 system for runaway processes (if @code{ps} still works).  Some process
3287 slots are normally reserved for use by @samp{root}.
3289 @item some-program terminated by signal 99
3290 Some program which was launched via @code{-exec} or similar was killed
3291 with a fatal signal.  This is just an advisory message.
3292 @end table
3296 @node Error Messages From xargs, Error Messages From locate, Error Messages From find, Error Messages
3297 @section Error Messages From xargs
3299 @table @samp
3300 @item environment is too large for exec
3301 This message means that you have so many environment variables set
3302 (or such large values for them) that there is no room within the
3303 system-imposed limits on program command-line argument length to
3304 invoke any program.  I'm sure you did this deliberately.  Please try
3305 unsetting some environment variables, or exiting the current shell.
3307 @item can not fit single argument within argument list size limit
3308 You are using the @samp{-i} option and @code{xargs} doesn't have
3309 enough space to build a command line because it has read in a really
3310 large item and it doesn't fit.  You can probably work around this
3311 problem with the @samp{-s} option, but the default size is pretty
3312 large.  You must be trying pretty hard to break @code{xargs}.
3314 @item cannot fork
3315 See the description of the similar message for @code{find}.
3317 @item <program>: exited with status 255; aborting
3318 When a command run by @code{xargs} exits with status 255, @code{xargs}
3319 is supposed to stop.  If this is not what you intended, wrap the
3320 program you are trying to invoke in a shell script which doesn't
3321 return status 255.
3323 @item <program>: terminated by signal 99
3324 See the description of the similar message for @code{find}.
3325 @end table
3327 @node Error Messages From locate, Error Messages From updatedb, Error Messages From xargs, Error Messages
3328 @section Error Messages From locate
3330 @table @samp
3331 @item warning: database `/usr/local/var/locatedb' is more than 8 days old
3332 The @code{locate} program relies on a database which is periodically
3333 built by the @code{updatedb} program.  That hasn't happened in a long
3334 time.  To fix this problem, run @code{updatedb} manually.  This can
3335 often happen on systems that are generally not left on, so the periodic
3336 ``cron'' task which normally does this doesn't get a chance to run.
3338 @item locate database `/usr/local/var/locatedb' is corrupt or invalid
3339 This should not happen.  Re-run @code{updatedb}.  If that works, but
3340 @code{locate} still produces this error, run @code{locate --version}
3341 and @code{updatedb --version}.  These should produce the same output.
3342 If not, you are using a mixed toolset; check your @samp{$PATH}
3343 environment variable and your shell aliases (if you have any).  If
3344 both programs claim to be GNU versions, this is a bug; all versions of
3345 these programs should interoperate without problem.  Ask for help on
3346 @email{bug-findutils@@gnu.org}.
3347 @end table
3350 @node Error Messages From updatedb, , Error Messages From locate, Error Messages
3351 @section Error Messages From updatedb
3353 The @code{updatedb} program (and the programs it invokes) do issue
3354 error messages, but none of them seem to me to be candidates for
3355 guidance.  If you are having a problem understanding one of these, ask
3356 for help on @email{bug-findutils@@gnu.org}.
3358 @node Primary Index, , Error Messages, Top
3359 @unnumbered @code{find} Primary Index
3361 This is a list of all of the primaries (tests, actions, and options)
3362 that make up @code{find} expressions for selecting files.  @xref{find
3363 Expressions}, for more information on expressions.
3365 @printindex fn
3367 @contents
3368 @bye
3370 @comment texi related words used by Emacs' spell checker ispell.el
3372 @comment LocalWords: texinfo setfilename settitle setchapternewpage
3373 @comment LocalWords: iftex finalout ifinfo DIR titlepage vskip pt
3374 @comment LocalWords: filll dir samp dfn noindent xref pxref
3375 @comment LocalWords: var deffn texi deffnx itemx emph asis
3376 @comment LocalWords: findex smallexample subsubsection cindex
3377 @comment LocalWords: dircategory direntry itemize
3379 @comment other words used by Emacs' spell checker ispell.el
3380 @comment LocalWords: README fred updatedb xargs Plett Rendell akefile
3381 @comment LocalWords: args grep Filesystems fo foo fOo wildcards iname
3382 @comment LocalWords: ipath regex iregex expr fubar regexps
3383 @comment LocalWords: metacharacters macs sr sc inode lname ilname
3384 @comment LocalWords: sysdep noleaf ls inum xdev filesystems usr atime
3385 @comment LocalWords: ctime mtime amin cmin mmin al daystart Sladkey rm
3386 @comment LocalWords: anewer cnewer bckw rf xtype uname gname uid gid
3387 @comment LocalWords: nouser nogroup chown chgrp perm ch maxdepth
3388 @comment LocalWords: mindepth cpio src CD AFS statted stat fstype ufs
3389 @comment LocalWords: nfs tmp mfs printf fprint dils rw djm Nov lwall
3390 @comment LocalWords: POSIXLY fls fprintf strftime locale's EDT GMT AP
3391 @comment LocalWords: EST diff perl backquotes sprintf Falstad Oct cron
3392 @comment LocalWords: eg vmunix mkdir afs allexec allwrite ARG bigram
3393 @comment LocalWords: bigrams cd chmod comp crc CVS dbfile dum eof
3394 @comment LocalWords: fileserver filesystem fn frcode Ghazi Hnewc iXX
3395 @comment LocalWords: joeuser Kaveh localpaths localuser LOGNAME
3396 @comment LocalWords: Meyering mv netpaths netuser nonblank nonblanks
3397 @comment LocalWords: ois ok Pinard printindex proc procs prunefs
3398 @comment LocalWords: prunepaths pwd RFS rmadillo rmdir rsh sbins str
3399 @comment LocalWords: su Timar ubins ug unstripped vf VM Weitzel
3400 @comment LocalWords: wildcard zlogout basename execdir wholename iwholename
3401 @comment LocalWords: timestamp timestamps Solaris FreeBSD OpenBSD POSIX