changes by David Engel
[findutils.git] / doc / find.texi
blob0b8d6f42887b1700a66ab6233c69a247589a5d45
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 @set EDITION 1.1
10 @set VERSION 4.1
11 @set UPDATED November 1994
13 @iftex
14 @finalout
15 @end iftex
17 @ifinfo
18 @format
19 START-INFO-DIR-ENTRY
20 * Finding Files: (find).        Listing and operating on files
21                                 that match certain criteria.
22 END-INFO-DIR-ENTRY
23 @end format
25 This file documents the GNU utilities for finding files that match
26 certain criteria and performing various operations on them.
28 Copyright (C) 1994 Free Software Foundation, Inc.
30 Permission is granted to make and distribute verbatim copies of
31 this manual provided the copyright notice and this permission notice
32 are preserved on all copies.
34 @ignore
35 Permission is granted to process this file through TeX and print the
36 results, provided the printed document carries copying permission
37 notice identical to this one except for the removal of this paragraph
38 (this paragraph not being relevant to the printed manual).
40 @end ignore
41 Permission is granted to copy and distribute modified versions of this
42 manual under the conditions for verbatim copying, provided that the entire
43 resulting derived work is distributed under the terms of a permission
44 notice identical to this one.
46 Permission is granted to copy and distribute translations of this manual
47 into another language, under the above conditions for modified versions,
48 except that this permission notice may be stated in a translation approved
49 by the Foundation.
50 @end ifinfo
52 @titlepage
53 @title Finding Files
54 @subtitle Edition @value{EDITION}, for GNU @code{find} version @value{VERSION}
55 @subtitle @value{UPDATED}
56 @author by David MacKenzie
58 @page
59 @vskip 0pt plus 1filll
60 Copyright @copyright{} 1994 Free Software Foundation, Inc.
62 Permission is granted to make and distribute verbatim copies of
63 this manual provided the copyright notice and this permission notice
64 are preserved on all copies.
66 Permission is granted to copy and distribute modified versions of this
67 manual under the conditions for verbatim copying, provided that the entire
68 resulting derived work is distributed under the terms of a permission
69 notice identical to this one.
71 Permission is granted to copy and distribute translations of this manual
72 into another language, under the above conditions for modified versions,
73 except that this permission notice may be stated in a translation approved
74 by the Foundation.
75 @end titlepage
77 @node Top, Introduction, , (dir)
78 @comment  node-name,  next,  previous,  up
80 @ifinfo
81 This file documents the GNU utilities for finding files that match
82 certain criteria and performing various actions on them.
83 This is edition @value{EDITION}, for @code{find} version @value{VERSION}.
84 @end ifinfo
86 @c The master menu, created with texinfo-master-menu, goes here.
88 @menu
89 * Introduction::                Summary of the tasks this manual describes.
90 * Finding Files::               Finding files that match certain criteria.
91 * Actions::                     Doing things to files you have found.
92 * Common Tasks::                Solutions to common real-world problems.
93 * Databases::                   Maintaining file name databases.
94 * File Permissions::            How to control access to files.
95 * Reference::                   Summary of how to invoke the programs.
96 * Primary Index::               The components of @code{find} expressions.
97 @end menu
99 @node Introduction, Finding Files, Top, Top
100 @chapter Introduction
102 This manual shows how to find files that meet criteria you specify, and
103 how to perform various actions on the files that you find.  The
104 principal programs that you use to perform these tasks are @code{find},
105 @code{locate}, and @code{xargs}.  Some of the examples in this manual
106 use capabilities specific to the GNU versions of those programs.
108 GNU @code{find} was originally written by Eric Decker, with enhancements
109 by David MacKenzie, Jay Plett, and Tim Wood.  GNU @code{xargs} was
110 originally written by Mike Rendell, with enhancements by David
111 MacKenzie.  GNU @code{locate} and its associated utilities were
112 originally written by James Woods, with enhancements by David MacKenzie.
113 The idea for @samp{find -print0} and @samp{xargs -0} came from Dan
114 Bernstein.  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-gnu-utils@@prep.ai.mit.edu}.  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.
308 @menu
309 * Name::
310 * Links::
311 * Time::
312 * Size::
313 * Type::
314 * Owner::
315 * Permissions::
316 * Contents::
317 * Directories::
318 * Filesystems::
319 * Combining Primaries With Operators::
320 @end menu
322 @node Name
323 @section Name
325 Here are ways to search for files whose name matches a certain pattern.
326 @xref{Shell Pattern Matching}, for a description of the @var{pattern}
327 arguments to these tests.
329 Each of these tests has a case-sensitive version and a case-insensitive
330 version, whose name begins with @samp{i}.  In a case-insensitive
331 comparison, the patterns @samp{fo*} and @samp{F??} match the file names
332 @file{Foo}, @samp{FOO}, @samp{foo}, @samp{fOo}, etc.
334 @menu
335 * Base Name Patterns::
336 * Full Name Patterns::
337 * Fast Full Name Search::
338 * Shell Pattern Matching::      Wildcards used by these programs.
339 @end menu
341 @node Base Name Patterns
342 @subsection Base Name Patterns
344 @deffn Test -name pattern
345 @deffnx Test -iname pattern
346 True if the base of the file name (the path with the leading directories
347 removed) matches shell pattern @var{pattern}.  For @samp{-iname}, the
348 match is case-insensitive.  To ignore a whole directory tree, use
349 @samp{-prune} (@pxref{Directories}).  As an example, to find Texinfo
350 source files in @file{/usr/local/doc}:
352 @example
353 find /usr/local/doc -name '*.texi'
354 @end example
355 @end deffn
357 @node Full Name Patterns
358 @subsection Full Name Patterns
360 @deffn Test -path pattern
361 @deffnx Test -ipath pattern
362 True if the entire file name, starting with the command line argument
363 under which the file was found, matches shell pattern @var{pattern}.
364 For @samp{-ipath}, the match is case-insensitive.  To ignore a whole
365 directory tree, use @samp{-prune} rather than checking every file in the
366 tree (@pxref{Directories}).
367 @end deffn
369 @deffn Test -regex expr
370 @deffnx Test -iregex expr
371 True if the entire file name matches regular expression @var{expr}.
372 This is a match on the whole path, not a search.  For example, to match
373 a file named @file{./fubar3}, you can use the regular expression
374 @samp{.*bar.} or @samp{.*b.*3}, but not @samp{b.*r3}.  @xref{Regexps, ,
375 Syntax of Regular Expressions, emacs, The GNU Emacs Manual}, for a
376 description of the syntax of regular expressions.  For @samp{-iregex},
377 the match is case-insensitive.
378 @end deffn
380 @node Fast Full Name Search
381 @subsection Fast Full Name Search
383 To search for files by name without having to actually scan the
384 directories on the disk (which can be slow), you can use the
385 @code{locate} program.  For each shell pattern you give it,
386 @code{locate} searches one or more databases of file names and displays
387 the file names that contain the pattern.  @xref{Shell Pattern Matching},
388 for details about shell patterns.
390 If a pattern is a plain string---it contains no
391 metacharacters---@code{locate} displays all file names in the database
392 that contain that string.  If a pattern contains
393 metacharacters, @code{locate} only displays file names that match the
394 pattern exactly.  As a result, patterns that contain metacharacters
395 should usually begin with a @samp{*}, and will most often end with one
396 as well.  The exceptions are patterns that are intended to explicitly
397 match the beginning or end of a file name.
399 The command
400 @example
401 locate @var{pattern}
402 @end example
404 is almost equivalent to
405 @example
406 find @var{directories} -name @var{pattern}
407 @end example
409 where @var{directories} are the directories for which the file name
410 databases contain information.  The differences are that the
411 @code{locate} information might be out of date, and that @code{locate}
412 handles wildcards in the pattern slightly differently than @code{find}
413 (@pxref{Shell Pattern Matching}).
415 The file name databases contain lists of files that were on the system
416 when the databases were last updated.  The system administrator can
417 choose the file name of the default database, the frequency with which
418 the databases are updated, and the directories for which they contain
419 entries.
421 Here is how to select which file name databases @code{locate} searches.
422 The default is system-dependent.
424 @table @code
425 @item --database=@var{path}
426 @itemx -d @var{path}
427 Instead of searching the default file name database, search the file
428 name databases in @var{path}, which is a colon-separated list of
429 database file names.  You can also use the environment variable
430 @code{LOCATE_PATH} to set the list of database files to search.  The
431 option overrides the environment variable if both are used.
432 @end table
434 @node Shell Pattern Matching
435 @subsection Shell Pattern Matching
437 @code{find} and @code{locate} can compare file names, or parts of file
438 names, to shell patterns.  A @dfn{shell pattern} is a string that may
439 contain the following special characters, which are known as
440 @dfn{wildcards} or @dfn{metacharacters}.
442 You must quote patterns that contain metacharacters to prevent the shell
443 from expanding them itself.  Double and single quotes both work; so does
444 escaping with a backslash.
446 @table @code
447 @item *
448 Matches any zero or more characters.
450 @item ?
451 Matches any one character.
453 @item [@var{string}]
454 Matches exactly one character that is a member of the string
455 @var{string}.  This is called a @dfn{character class}.  As a shorthand,
456 @var{string} may contain ranges, which consist of two characters with a
457 dash between them.  For example, the class @samp{[a-z0-9_]} matches a
458 lowercase letter, a number, or an underscore.  You can negate a class by
459 placing a @samp{!} or @samp{^} immediately after the opening bracket.
460 Thus, @samp{[^A-Z@@]} matches any character except an uppercase letter
461 or an at sign.
463 @item \
464 Removes the special meaning of the character that follows it.  This
465 works even in character classes.
466 @end table
468 In the @code{find} tests that do shell pattern matching (@samp{-name},
469 @samp{-path}, etc.), wildcards in the pattern do not match a @samp{.}
470 at the beginning of a file name.  This is not the case for
471 @code{locate}.  Thus, @samp{find -name '*macs'} does not match a file
472 named @file{.emacs}, but @samp{locate '*macs'} does.
474 Slash characters have no special significance in the shell pattern
475 matching that @code{find} and @code{locate} do, unlike in the shell, in
476 which wildcards do not match them.  Therefore, a pattern @samp{foo*bar}
477 can match a file name @samp{foo3/bar}, and a pattern @samp{./sr*sc} can
478 match a file name @samp{./src/misc}.
480 @node Links
481 @section Links
483 There are two ways that files can be linked together.  @dfn{Symbolic
484 links} are a special type of file whose contents are a portion of the
485 name of another file.  @dfn{Hard links} are multiple directory entries
486 for one file; the file names all have the same index node (@dfn{inode})
487 number on the disk.
489 @menu
490 * Symbolic Links::
491 * Hard Links::
492 @end menu
494 @node Symbolic Links
495 @subsection Symbolic Links
497 @deffn Test -lname pattern
498 @deffnx Test -ilname pattern
499 True if the file is a symbolic link whose contents match shell pattern
500 @var{pattern}.  For @samp{-ilname}, the match is case-insensitive.
501 @xref{Shell Pattern Matching}, for details about the @var{pattern}
502 argument.  So, to list any symbolic links to @file{sysdep.c} in the
503 current directory and its subdirectories, you can do:
505 @example
506 find . -lname '*sysdep.c'
507 @end example
508 @end deffn
510 @deffn Option -follow
511 Dereference symbolic links.  The following differences in behavior occur
512 when this option is given:
514 @itemize @bullet
515 @item
516 @code{find} follows symbolic links to directories when searching
517 directory trees.
518 @item
519 @samp{-lname} and @samp{-ilname} always return false.
520 @item
521 @samp{-type} reports the types of the files that symbolic links point
523 @item
524 Implies @samp{-noleaf} (@pxref{Directories}).
525 @end itemize
526 @end deffn
528 @node Hard Links
529 @subsection Hard Links
531 To find hard links, first get the inode number of the file whose links
532 you want to find.  You can learn a file's inode number and the number of
533 links to it by running @samp{ls -i} or @samp{find -ls}.  If the file has
534 more than one link, you can search for the other links by passing that
535 inode number to @samp{-inum}.  Add the @samp{-xdev} option if you are
536 starting the search at a directory that has other filesystems mounted on
537 it, such as @file{/usr} on many systems.  Doing this saves needless
538 searching, since hard links to a file must be on the same filesystem.
539 @xref{Filesystems}.
541 @deffn Test -inum n
542 File has inode number @var{n}.
543 @end deffn
545 You can also search for files that have a certain number of links, with
546 @samp{-links}.  Directories normally have at least two hard links; their
547 @file{.} entry is the second one.  If they have subdirectories, each of
548 those also has a hard link called @file{..} to its parent directory.
550 @deffn Test -links n
551 File has @var{n} hard links.
552 @end deffn
554 @node Time
555 @section Time
557 Each file has three time stamps, which record the last time that certain
558 operations were performed on the file:
560 @enumerate
561 @item
562 access (read the file's contents)
563 @item
564 change the status (modify the file or its attributes)
565 @item
566 modify (change the file's contents)
567 @end enumerate
569 You can search for files whose time stamps are within a certain age
570 range, or compare them to other time stamps.
572 @menu
573 * Age Ranges::
574 * Comparing Timestamps::
575 @end menu
577 @node Age Ranges
578 @subsection Age Ranges
580 These tests are mainly useful with ranges (@samp{+@var{n}} and
581 @samp{-@var{n}}).
583 @deffn Test -atime n
584 @deffnx Test -ctime n
585 @deffnx Test -mtime n
586 True if the file was last accessed (or its status changed, or it was
587 modified) @var{n}*24 hours ago.
588 @end deffn
590 @deffn Test -amin n
591 @deffnx Test -cmin n
592 @deffnx Test -mmin n
593 True if the file was last accessed (or its status changed, or it was
594 modified) @var{n} minutes ago.  These tests provide finer granularity of
595 measurement than @samp{-atime} et al.  For example, to list files in
596 @file{/u/bill} that were last read from 2 to 6 hours ago:
598 @example
599 find /u/bill -amin +2 -amin -6
600 @end example
601 @end deffn
603 @deffn Option -daystart
604 Measure times from the beginning of today rather than from 24 hours ago.
605 So, to list the regular files in your home directory that were modified
606 yesterday, do
608 @example
609 find ~ -daystart -type f -mtime 1
610 @end example
611 @end deffn
613 @node Comparing Timestamps
614 @subsection Comparing Timestamps
616 As an alternative to comparing timestamps to the current time, you can
617 compare them to another file's timestamp.  That file's timestamp could
618 be updated by another program when some event occurs.  Or you could set
619 it to a particular fixed date using the @code{touch} command.  For
620 example, to list files in @file{/usr} modified after February 1 of the
621 current year:
623 @c Idea from Rick Sladkey.
624 @example
625 touch -t 02010000 /tmp/stamp$$
626 find /usr -newer /tmp/stamp$$
627 rm -f /tmp/stamp$$
628 @end example
630 @deffn Test -anewer file
631 @deffnx Test -cnewer file
632 @deffnx Test -newer file
633 True if the file was last accessed (or its status changed, or it was
634 modified) more recently than @var{file} was modified.  These tests are
635 affected by @samp{-follow} only if @samp{-follow} comes before them on
636 the command line.  @xref{Symbolic Links}, for more information on
637 @samp{-follow}.  As an example, to list any files modified since
638 @file{/bin/sh} was last modified:
640 @example
641 find . -newer /bin/sh
642 @end example
643 @end deffn
645 @deffn Test -used n
646 True if the file was last accessed @var{n} days after its status was
647 last changed.  Useful for finding files that are not being used, and
648 could perhaps be archived or removed to save disk space.
649 @end deffn
651 @node Size
652 @section Size
654 @deffn Test -size n@r{[}bckw@r{]}
655 True if the file uses @var{n} units of space, rounding up.  The units
656 are 512-byte blocks by default, but they can be changed by adding a
657 one-character suffix to @var{n}:
659 @table @code
660 @item b
661 512-byte blocks
662 @item c
663 bytes
664 @item k
665 kilobytes (1024 bytes)
666 @item w
667 2-byte words
668 @end table
670 The size does not count indirect blocks, but it does count blocks in
671 sparse files that are not actually allocated.
672 @end deffn
674 @deffn Test -empty
675 True if the file is empty and is either a regular file or a directory.
676 This might make it a good candidate for deletion.  This test is useful
677 with @samp{-depth} (@pxref{Directories}) and @samp{-exec rm -rf '@{@}' ';'}
678 (@pxref{Single File}).
679 @end deffn
681 @node Type
682 @section Type
684 @deffn Test -type c
685 True if the file is of type @var{c}:
687 @table @code
688 @item b
689 block (buffered) special
690 @item c
691 character (unbuffered) special
692 @item d
693 directory
694 @item p
695 named pipe (FIFO)
696 @item f
697 regular file
698 @item l
699 symbolic link
700 @item s
701 socket
702 @end table
703 @end deffn
705 @deffn Test -xtype c
706 The same as @samp{-type} unless the file is a symbolic link.  For
707 symbolic links: if @samp{-follow} has not been given, true if the file
708 is a link to a file of type @var{c}; if @samp{-follow} has been given,
709 true if @var{c} is @samp{l}.  In other words, for symbolic links,
710 @samp{-xtype} checks the type of the file that @samp{-type} does not
711 check.  @xref{Symbolic Links}, for more information on @samp{-follow}.
712 @end deffn
714 @node Owner
715 @section Owner
717 @deffn Test -user uname
718 @deffnx Test -group gname
719 True if the file is owned by user @var{uname} (belongs to group @var{gname}).
720 A numeric ID is allowed.
721 @end deffn
723 @deffn Test -uid n
724 @deffnx Test -gid n
725 True if the file's numeric user ID (group ID) is @var{n}.  These tests
726 support ranges (@samp{+@var{n}} and @samp{-@var{n}}), unlike
727 @samp{-user} and @samp{-group}.
728 @end deffn
730 @deffn Test -nouser
731 @deffnx Test -nogroup
732 True if no user corresponds to the file's numeric user ID (no group
733 corresponds to the numeric group ID).  These cases usually mean that the
734 files belonged to users who have since been removed from the system.
735 You probably should change the ownership of such files to an existing
736 user or group, using the @code{chown} or @code{chgrp} program.
737 @end deffn
739 @node Permissions
740 @section Permissions
742 @xref{File Permissions}, for information on how file permissions are
743 structured and how to specify them.
745 @deffn Test -perm mode
746 True if the
747 file's permissions are exactly @var{mode} (which can be numeric or symbolic).
748 Symbolic modes use mode 0 as a point of departure.
749 If @var{mode} starts with @samp{-}, true if
750 @emph{all} of the permissions set in @var{mode} are set for the file;
751 permissions not set in @var{mode} are ignored.
752 If @var{mode} starts with @samp{+}, true if
753 @emph{any} of the permissions set in @var{mode} are set for the file;
754 permissions not set in @var{mode} are ignored.
755 @end deffn
757 @node Contents
758 @section Contents
760 To search for files based on their contents, you can use the @code{grep}
761 program.  For example, to find out which C source files in the current
762 directory contain the string @samp{thing}, you can do:
764 @example
765 grep -l thing *.[ch]
766 @end example
768 If you also want to search for the string in files in subdirectories,
769 you can combine @code{grep} with @code{find} and @code{xargs}, like
770 this:
772 @example
773 find . -name '*.[ch]' | xargs grep -l thing
774 @end example
776 The @samp{-l} option causes @code{grep} to print only the names of files
777 that contain the string, rather than the lines that contain it.  The
778 string argument (@samp{thing}) is actually a regular expression, so it
779 can contain metacharacters.  This method can be refined a little by
780 using the @samp{-r} option to make @code{xargs} not run @code{grep} if
781 @code{find} produces no output, and using the @code{find} action
782 @samp{-print0} and the @code{xargs} option @samp{-0} to avoid
783 misinterpreting files whose names contain spaces:
785 @example
786 find . -name '*.[ch]' -print0 | xargs -r -0 grep -l thing
787 @end example
789 For a fuller treatment of finding files whose contents match a pattern,
790 see the manual page for @code{grep}.
792 @node Directories
793 @section Directories
795 Here is how to control which directories @code{find} searches, and how
796 it searches them.  These two options allow you to process a horizontal
797 slice of a directory tree.
799 @deffn Option -maxdepth levels
800 Descend at most @var{levels} (a non-negative integer) levels of
801 directories below the command line arguments.  @samp{-maxdepth 0} means
802 only apply the tests and actions to the command line arguments.
803 @end deffn
805 @deffn Option -mindepth levels
806 Do not apply any tests or actions at levels less than @var{levels} (a
807 non-negative integer).  @samp{-mindepth 1} means process all files
808 except the command line arguments.
809 @end deffn
811 @deffn Option -depth
812 Process each directory's contents before the directory itself.  Doing
813 this is a good idea when producing lists of files to archive with
814 @code{cpio} or @code{tar}.  If a directory does not have write
815 permission for its owner, its contents can still be restored from the
816 archive since the directory's permissions are restored after its contents.
817 @end deffn
819 @deffn Action -prune
820 If @samp{-depth} is not given, true; do not descend the current
821 directory.  If @samp{-depth} is given, false; no effect.  @samp{-prune}
822 only affects tests and actions that come after it in the expression, not
823 those that come before.
825 For example, to skip the directory @file{src/emacs} and all files and
826 directories under it, and print the names of the other files found:
828 @example
829 find . -path './src/emacs' -prune -o -print
830 @end example
831 @end deffn
833 @deffn Option -noleaf
834 Do not optimize by assuming that directories contain 2 fewer
835 subdirectories than their hard link count.  This option is needed when
836 searching filesystems that do not follow the Unix directory-link
837 convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount
838 points.  Each directory on a normal Unix filesystem has at least 2 hard
839 links: its name and its @file{.}  entry.  Additionally, its
840 subdirectories (if any) each have a @file{..}  entry linked to that
841 directory.  When @code{find} is examining a directory, after it has
842 statted 2 fewer subdirectories than the directory's link count, it knows
843 that the rest of the entries in the directory are non-directories
844 (@dfn{leaf} files in the directory tree).  If only the files' names need
845 to be examined, there is no need to stat them; this gives a significant
846 increase in search speed.
847 @end deffn
849 @node Filesystems
850 @section Filesystems
852 A @dfn{filesystem} is a section of a disk, either on the local host or
853 mounted from a remote host over a network.  Searching network
854 filesystems can be slow, so it is common to make @code{find} avoid them.
856 There are two ways to avoid searching certain filesystems.  One way is
857 to tell @code{find} to only search one filesystem:
859 @deffn Option -xdev
860 @deffnx Option -mount
861 Don't descend directories on other filesystems.  These options are synonyms.
862 @end deffn
864 The other way is to check the type of filesystem each file is on, and
865 not descend directories that are on undesirable filesystem types:
867 @deffn Test -fstype type
868 True if the file is on a filesystem of type @var{type}.  The valid
869 filesystem types vary among different versions of Unix; an incomplete
870 list of filesystem types that are accepted on some version of Unix or
871 another is:
872 @example
873 ufs 4.2 4.3 nfs tmp mfs S51K S52K
874 @end example
875 You can use @samp{-printf} with the @samp{%F} directive to see the types
876 of your filesystems.  @xref{Print File Information}.  @samp{-fstype} is
877 usually used with @samp{-prune} to avoid searching remote filesystems
878 (@pxref{Directories}). 
879 @end deffn
881 @node Combining Primaries With Operators
882 @section Combining Primaries With Operators
884 Operators build a complex expression from tests and actions.
885 The operators are, in order of decreasing precedence:
887 @table @code
888 @item @asis{( @var{expr} )}
889 Force precedence.  True if @var{expr} is true.
891 @item @asis{! @var{expr}}
892 @itemx @asis{-not @var{expr}}
893 True if @var{expr} is false.
895 @item @asis{@var{expr1 expr2}}
896 @itemx @asis{@var{expr1} -a @var{expr2}}
897 @itemx @asis{@var{expr1} -and @var{expr2}}
898 And; @var{expr2} is not evaluated if @var{expr1} is false.
900 @item @asis{@var{expr1} -o @var{expr2}}
901 @itemx @asis{@var{expr1} -or @var{expr2}}
902 Or; @var{expr2} is not evaluated if @var{expr1} is true.
904 @item @asis{@var{expr1} , @var{expr2}}
905 List; both @var{expr1} and @var{expr2} are always evaluated.  True if
906 @var{expr2} is true.  The value of @var{expr1} is discarded.  This
907 operator lets you do multiple independent operations on one traversal,
908 without depending on whether other operations succeeded.
909 @end table
911 @code{find} searches the directory tree rooted at each file name by
912 evaluating the expression from left to right, according to the rules of
913 precedence, until the outcome is known (the left hand side is false for
914 @samp{-and}, true for @samp{-or}), at which point @code{find} moves on
915 to the next file name.
917 There are two other tests that can be useful in complex expressions:
919 @deffn Test -true
920 Always true.
921 @end deffn
923 @deffn Test -false
924 Always false.
925 @end deffn
927 @node Actions, Common Tasks, Finding Files, Top
928 @chapter Actions
930 There are several ways you can print information about the files that
931 match the criteria you gave in the @code{find} expression.  You can
932 print the information either to the standard output or to a file that
933 you name.  You can also execute commands that have the file names as
934 arguments.  You can use those commands as further filters to select files.
936 @menu
937 * Print File Name::
938 * Print File Information::
939 * Run Commands::
940 * Adding Tests::
941 @end menu
943 @node Print File Name
944 @section Print File Name
946 @deffn Action -print
947 True; print the full file name on the standard output, followed by a
948 newline.
949 @end deffn
951 @deffn Action -fprint file
952 True; print the full file name into file @var{file}, followed by a
953 newline.  If @var{file} does not exist when @code{find} is run, it is
954 created; if it does exist, it is truncated to 0 bytes.  The file names
955 @file{/dev/stdout} and @file{/dev/stderr} are handled specially; they
956 refer to the standard output and standard error output, respectively.
957 @end deffn
959 @node Print File Information
960 @section Print File Information
962 @deffn Action -ls
963 True; list the current file in @samp{ls -dils} format on the standard
964 output.  The output looks like this:
966 @smallexample
967 204744   17 -rw-r--r--   1 djm      staff       17337 Nov  2  1992 ./lwall-quotes
968 @end smallexample
970 The fields are:
972 @enumerate
973 @item
974 The inode number of the file.  @xref{Hard Links}, for how to find files
975 based on their inode number.
977 @item
978 the number of blocks in the file.  The block counts are of 1K blocks,
979 unless the environment variable @code{POSIXLY_CORRECT} is set, in which
980 case 512-byte blocks are used.  @xref{Size}, for how to find files based
981 on their size.
983 @item
984 The file's type and permissions.  The type is shown as a dash for a
985 regular file; for other file types, a letter like for @samp{-type} is
986 used (@pxref{Type}).  The permissions are read, write, and execute for
987 the file's owner, its group, and other users, respectively; a dash means
988 the permission is not granted.  @xref{File Permissions}, for more details
989 about file permissions.  @xref{Permissions}, for how to find files based
990 on their permissions.
992 @item
993 The number of hard links to the file.
995 @item
996 The user who owns the file.
998 @item
999 The file's group.
1001 @item
1002 The file's size in bytes.
1004 @item
1005 The date the file was last modified.
1007 @item
1008 The file's name.  @samp{-ls} quotes non-printable characters in the file
1009 names using C-like backslash escapes.
1010 @end enumerate
1011 @end deffn
1013 @deffn Action -fls file
1014 True; like @samp{-ls} but write to @var{file} like @samp{-fprint}
1015 (@pxref{Print File Name}).
1016 @end deffn
1018 @deffn Action -printf format
1019 True; print @var{format} on the standard output, interpreting @samp{\}
1020 escapes and @samp{%} directives.  Field widths and precisions can be
1021 specified as with the @code{printf} C function.  Unlike @samp{-print},
1022 @samp{-printf} does not add a newline at the end of the string.
1023 @end deffn
1025 @deffn Action -fprintf file format
1026 True; like @samp{-printf} but write to @var{file} like @samp{-fprint}
1027 (@pxref{Print File Name}).
1028 @end deffn
1030 @menu
1031 * Escapes::
1032 * Format Directives::
1033 * Time Formats::
1034 @end menu
1036 @node Escapes
1037 @subsection Escapes
1039 The escapes that @samp{-printf} and @samp{-fprintf} recognize are:
1041 @table @code
1042 @item \a
1043 Alarm bell.
1044 @item \b
1045 Backspace.
1046 @item \c
1047 Stop printing from this format immediately and flush the output.
1048 @item \f
1049 Form feed.
1050 @item \n
1051 Newline.
1052 @item \r
1053 Carriage return.
1054 @item \t
1055 Horizontal tab.
1056 @item \v
1057 Vertical tab.
1058 @item \\
1059 A literal backslash (@samp{\}).
1060 @end table
1062 A @samp{\} character followed by any other character is treated as an
1063 ordinary character, so they both are printed, and a warning message is
1064 printed to the standard error output (because it was probably a typo).
1066 @node Format Directives
1067 @subsection Format Directives
1069 @samp{-printf} and @samp{-fprintf} support the following format
1070 directives to print information about the file being processed.  Unlike
1071 the C @code{printf} function, they do not support field width specifiers.
1073 @samp{%%} is a literal percent sign.  A @samp{%} character followed by
1074 any other character is discarded (but the other character is printed),
1075 and a warning message is printed to the standard error output (because
1076 it was probably a typo).
1078 @menu
1079 * Name Directives::
1080 * Ownership Directives::
1081 * Size Directives::
1082 * Location Directives::
1083 * Time Directives::
1084 @end menu
1086 @node Name Directives
1087 @subsubsection Name Directives
1089 @table @code
1090 @item %p
1091 File's name.
1092 @item %f
1093 File's name with any leading directories removed (only the last element).
1094 @item %h
1095 Leading directories of file's name (all but the last element and the
1096 slash before it).
1097 @item %P
1098 File's name with the name of the command line argument under which
1099 it was found removed from the beginning.
1100 @item %H
1101 Command line argument under which file was found.
1102 @end table
1104 @node Ownership Directives
1105 @subsubsection Ownership Directives
1107 @table @code
1108 @item %g
1109 File's group name, or numeric group ID if the group has no name.
1110 @item %G
1111 File's numeric group ID.
1112 @item %u
1113 File's user name, or numeric user ID if the user has no name.
1114 @item %U
1115 File's numeric user ID.
1116 @item %m
1117 File's permissions (in octal).
1118 @end table
1120 @node Size Directives
1121 @subsubsection Size Directives
1123 @table @code
1124 @item %k
1125 File's size in 1K blocks (rounded up).
1126 @item %b
1127 File's size in 512-byte blocks (rounded up).
1128 @item %s
1129 File's size in bytes.
1130 @end table
1132 @node Location Directives
1133 @subsubsection Location Directives
1135 @table @code
1136 @item %d
1137 File's depth in the directory tree; files named on the command line
1138 have a depth of 0.
1139 @item %F
1140 Type of the filesystem the file is on; this value can be used for
1141 @samp{-fstype} (@pxref{Directories}).
1142 @item %l
1143 Object of symbolic link (empty string if file is not a symbolic link).
1144 @item %i
1145 File's inode number (in decimal).
1146 @item %n
1147 Number of hard links to file.
1148 @end table
1150 @node Time Directives
1151 @subsubsection Time Directives
1153 Some of these directives use the C @code{ctime} function.  Its output
1154 depends on the current locale, but it typically looks like
1156 @example
1157 Wed Nov  2 00:42:36 1994
1158 @end example
1160 @table @code
1161 @item %a
1162 File's last access time in the format returned by the C @code{ctime} function.
1163 @item %A@var{k}
1164 File's last access time in the format specified by @var{k}
1165 (@pxref{Time Formats}). 
1166 @item %c
1167 File's last status change time in the format returned by the C @code{ctime}
1168 function.
1169 @item %C@var{k}
1170 File's last status change time in the format specified by @var{k}
1171 (@pxref{Time Formats}).
1172 @item %t
1173 File's last modification time in the format returned by the C @code{ctime}
1174 function.
1175 @item %T@var{k}
1176 File's last modification time in the format specified by @var{k} 
1177 (@pxref{Time Formats}). 
1178 @end table
1180 @node Time Formats
1181 @subsection Time Formats
1183 Below are the formats for the directives @samp{%A}, @samp{%C}, and
1184 @samp{%T}, which print the file's timestamps.  Some of these formats
1185 might not be available on all systems, due to differences in the C
1186 @code{strftime} function between systems.
1188 @menu
1189 * Time Components::
1190 * Date Components::
1191 * Combined Time Formats::
1192 @end menu
1194 @node Time Components
1195 @subsubsection Time Components
1197 The following format directives print single components of the time.
1199 @table @code
1200 @item H
1201 hour (00..23)
1202 @item I
1203 hour (01..12)
1204 @item k
1205 hour ( 0..23)
1206 @item l
1207 hour ( 1..12)
1208 @item p
1209 locale's AM or PM
1210 @item Z
1211 time zone (e.g., EDT), or nothing if no time zone is determinable
1212 @item M
1213 minute (00..59)
1214 @item S
1215 second (00..61)
1216 @item @@
1217 seconds since Jan. 1, 1970, 00:00 GMT.
1218 @end table
1220 @node Date Components
1221 @subsubsection Date Components
1223 The following format directives print single components of the date.
1225 @table @code
1226 @item a
1227 locale's abbreviated weekday name (Sun..Sat)
1228 @item A
1229 locale's full weekday name, variable length (Sunday..Saturday)
1230 @item b
1231 @itemx h
1232 locale's abbreviated month name (Jan..Dec)
1233 @item B
1234 locale's full month name, variable length (January..December)
1235 @item m
1236 month (01..12)
1237 @item d
1238 day of month (01..31)
1239 @item w
1240 day of week (0..6)
1241 @item j
1242 day of year (001..366)
1243 @item U
1244 week number of year with Sunday as first day of week (00..53)
1245 @item W
1246 week number of year with Monday as first day of week (00..53)
1247 @item Y
1248 year (1970@dots{})
1249 @item y
1250 last two digits of year (00..99)
1251 @end table
1253 @node Combined Time Formats
1254 @subsubsection Combined Time Formats
1256 The following format directives print combinations of time and date
1257 components. 
1259 @table @code
1260 @item r
1261 time, 12-hour (hh:mm:ss [AP]M)
1262 @item T
1263 time, 24-hour (hh:mm:ss)
1264 @item X
1265 locale's time representation (H:M:S)
1266 @item c
1267 locale's date and time (Sat Nov 04 12:02:33 EST 1989)
1268 @item D
1269 date (mm/dd/yy)
1270 @item x
1271 locale's date representation (mm/dd/yy)
1272 @end table
1274 @node Run Commands
1275 @section Run Commands
1277 You can use the list of file names created by @code{find} or
1278 @code{locate} as arguments to other commands.  In this way you can
1279 perform arbitrary actions on the files.
1281 @menu
1282 * Single File::
1283 * Multiple Files::
1284 * Querying::
1285 @end menu
1287 @node Single File
1288 @subsection Single File
1290 Here is how to run a command on one file at a time.
1292 @deffn Action -exec command ;
1293 Execute @var{command}; true if 0 status is returned.  @code{find} takes
1294 all arguments after @samp{-exec} to be part of the command until an
1295 argument consisting of @samp{;} is reached.  It replaces the string
1296 @samp{@{@}} by the current file name being processed everywhere it
1297 occurs in the command.  Both of these constructions need to be escaped
1298 (with a @samp{\}) or quoted to protect them from expansion by the shell.
1299 The command is executed in the directory in which @code{find} was run.
1301 For example, to compare each C header file in the current directory with
1302 the file @file{/tmp/master}:
1304 @example
1305 find . -name '*.h' -exec diff -u '@{@}' /tmp/master ';'
1306 @end example
1307 @end deffn
1309 @node Multiple Files
1310 @subsection Multiple Files
1312 Sometimes you need to process files alone.  But when you
1313 don't, it is faster to run a command on as many files as possible at a
1314 time, rather than once per file.  Doing this saves on the time it takes
1315 to start up the command each time.
1317 To run a command on more than one file at once, use the @code{xargs}
1318 command, which is invoked like this:
1320 @example
1321 xargs @r{[}@var{option}@dots{}@r{]} @r{[}@var{command} @r{[}@var{initial-arguments}@r{]}@r{]}
1322 @end example
1324 @code{xargs} reads arguments from the standard input, delimited by
1325 blanks (which can be protected with double or single quotes or a
1326 backslash) or newlines.  It executes the @var{command} (default is
1327 @file{/bin/echo}) one or more times with any @var{initial-arguments}
1328 followed by arguments read from standard input.  Blank lines on the
1329 standard input are ignored.
1331 Instead of blank-delimited names, it is safer to use @samp{find -print0}
1332 or @samp{find -fprint0} and process the output by giving the @samp{-0}
1333 or @samp{--null} option to GNU @code{xargs}, GNU @code{tar}, GNU
1334 @code{cpio}, or @code{perl}.
1336 You can use shell command substitution (backquotes) to process a list of
1337 arguments, like this:
1339 @example
1340 grep -l sprintf `find $HOME -name '*.c' -print`
1341 @end example
1343 However, that method produces an error if the length of the @samp{.c}
1344 file names exceeds the operating system's command-line length limit.
1345 @code{xargs} avoids that problem by running the command as many times as
1346 necessary without exceeding the limit:
1348 @example
1349 find $HOME -name '*.c' -print | grep -l sprintf
1350 @end example
1352 However, if the command needs to have its standard input be a terminal
1353 (@code{less}, for example), you have to use the shell command
1354 substitution method.
1356 @menu
1357 * Unsafe File Name Handling::
1358 * Safe File Name Handling::
1359 * Limiting Command Size::
1360 * Interspersing File Names::
1361 @end menu
1363 @node Unsafe File Name Handling
1364 @subsubsection Unsafe File Name Handling
1366 Because file names can contain quotes, backslashes, blank characters,
1367 and even newlines, it is not safe to process them using @code{xargs} in its
1368 default mode of operation.  But since most files' names do not contain
1369 blanks, this problem occurs only infrequently.  If you are only
1370 searching through files that you know have safe names, then you need not
1371 be concerned about it.
1373 @c This example is adapted from:
1374 @c From: pfalstad@stone.Princeton.EDU (Paul John Falstad)
1375 @c Newsgroups: comp.unix.shell
1376 @c Subject: Re: Beware xargs security holes
1377 @c Date: 16 Oct 90 19:12:06 GMT
1378 @c 
1379 In many applications, if @code{xargs} botches processing a file because
1380 its name contains special characters, some data might be lost.  The
1381 importance of this problem depends on the importance of the data and
1382 whether anyone notices the loss soon enough to correct it.  However,
1383 here is an extreme example of the problems that using blank-delimited
1384 names can cause.  If the following command is run daily from
1385 @code{cron}, then any user can remove any file on the system:
1387 @example
1388 find / -name '#*' -atime +7 -print | xargs rm
1389 @end example
1391 For example, you could do something like this:
1393 @example
1394 eg$ echo > '#
1395 vmunix'
1396 @end example
1398 @noindent
1399 and then @code{cron} would delete @file{/vmunix}, if it ran
1400 @code{xargs} with @file{/} as its current directory.
1402 To delete other files, for example @file{/u/joeuser/.plan}, you could do
1403 this:
1405 @example
1406 eg$ mkdir '#
1408 eg$ cd '#
1410 eg$ mkdir u u/joeuser u/joeuser/.plan'
1412 eg$ echo > u/joeuser/.plan'
1413 /#foo'
1414 eg$ cd ..
1415 eg$ find . -name '#*' -print | xargs echo
1416 ./# ./# /u/joeuser/.plan /#foo
1417 @end example
1419 @node Safe File Name Handling
1420 @subsubsection Safe File Name Handling
1422 Here is how to make @code{find} output file names so that they can be
1423 used by other programs without being mangled or misinterpreted.  You can
1424 process file names generated this way by giving the @samp{-0} or
1425 @samp{--null} option to GNU @code{xargs}, GNU @code{tar}, GNU
1426 @code{cpio}, or @code{perl}.
1428 @deffn Action -print0
1429 True; print the full file name on the standard output, followed by a
1430 null character.
1431 @end deffn
1433 @deffn Action -fprint0 file
1434 True; like @samp{-print0} but write to @var{file} like @samp{-fprint}
1435 (@pxref{Print File Name}).
1436 @end deffn
1438 @node Limiting Command Size
1439 @subsubsection Limiting Command Size
1441 @code{xargs} gives you control over how many arguments it passes to the
1442 command each time it executes it.  By default, it uses up to
1443 @code{ARG_MAX} - 2k, or 20k, whichever is smaller, characters per
1444 command.  It uses as many lines and arguments as fit within that limit.
1445 The following options modify those values.
1447 @table @code
1448 @item --no-run-if-empty
1449 @itemx -r
1450 If the standard input does not contain any nonblanks, do not run the
1451 command.  By default, the command is run once even if there is no input.
1453 @item --max-lines@r{[}=@var{max-lines}@r{]}
1454 @itemx -l@r{[}@var{max-lines}@r{]}
1455 Use at most @var{max-lines} nonblank input lines per command line;
1456 @var{max-lines} defaults to 1 if omitted.  Trailing blanks cause an
1457 input line to be logically continued on the next input line, for the
1458 purpose of counting the lines.  Implies @samp{-x}.
1460 @item --max-args=@var{max-args}
1461 @itemx -n @var{max-args}
1462 Use at most @var{max-args} arguments per command line.  Fewer than
1463 @var{max-args} arguments will be used if the size (see the @samp{-s}
1464 option) is exceeded, unless the @samp{-x} option is given, in which case
1465 @code{xargs} will exit.
1467 @item --max-chars=@var{max-chars}
1468 @itemx -s @var{max-chars}
1469 Use at most @var{max-chars} characters per command line, including the
1470 command and initial arguments and the terminating nulls at the ends of
1471 the argument strings.
1473 @item --max-procs=@var{max-procs}
1474 @itemx -P @var{max-procs}
1475 Run up to @var{max-procs} processes at a time; the default is 1.  If
1476 @var{max-procs} is 0, @code{xargs} will run as many processes as
1477 possible at a time.  Use the @samp{-n}, @samp{-s}, or @samp{-l} option
1478 with @samp{-P}; otherwise chances are that the command will be run only
1479 once.
1480 @end table
1482 @node Interspersing File Names
1483 @subsubsection Interspersing File Names
1485 @code{xargs} can insert the name of the file it is processing between
1486 arguments you give for the command.  Unless you also give options to
1487 limit the command size (@pxref{Limiting Command Size}), this mode of
1488 operation is equivalent to @samp{find -exec} (@pxref{Single File}).
1490 @table @code
1491 @item --replace@r{[}=@var{replace-str}@r{]}
1492 @itemx -i@r{[}@var{replace-str}@r{]}
1493 Replace occurences of @var{replace-str} in the initial arguments with
1494 names read from standard input.  Also, unquoted blanks do not terminate
1495 arguments.  If @var{replace-str} is omitted, it defaults to @samp{@{@}}
1496 (like for @samp{find -exec}).  Implies @samp{-x} and @samp{-l 1}.  As an
1497 example, to sort each file the @file{bills} directory, leaving the
1498 output in that file name with @file{.sorted} appended, you could do:
1500 @example
1501 find bills -type f | xargs -iXX sort -o XX.sorted XX
1502 @end example
1504 @noindent
1505 The equivalent command using @samp{find -exec} is:
1507 @example
1508 find bills -type f -exec sort -o '@{@}.sorted' '@{@}' ';'
1509 @end example
1510 @end table
1512 @node Querying
1513 @subsection Querying
1515 To ask the user whether to execute a command on a single file, you can
1516 use the @code{find} primary @samp{-ok} instead of @samp{-exec}:
1518 @deffn Action -ok command ;
1519 Like @samp{-exec} (@pxref{Single File}), but ask the user first (on
1520 the standard input); if the response does not start with @samp{y} or
1521 @samp{Y}, do not run the command, and return false.
1522 @end deffn
1524 When processing multiple files with a single command, to query the user
1525 you give @code{xargs} the following option.  When using this option, you
1526 might find it useful to control the number of files processed per
1527 invocation of the command (@pxref{Limiting Command Size}).
1529 @table @code
1530 @item --interactive
1531 @itemx -p
1532 Prompt the user about whether to run each command line and read a line
1533 from the terminal.  Only run the command line if the response starts
1534 with @samp{y} or @samp{Y}.  Implies @samp{-t}.
1535 @end table
1537 @node Adding Tests
1538 @section Adding Tests
1540 You can test for file attributes that none of the @code{find} builtin
1541 tests check.  To do this, use @code{xargs} to run a program that filters
1542 a list of files printed by @code{find}.  If possible, use @code{find}
1543 builtin tests to pare down the list, so the program run by @code{xargs}
1544 has less work to do.  The tests builtin to @code{find} will likely run
1545 faster than tests that other programs perform.
1547 For example, here is a way to print the names of all of the unstripped
1548 binaries in the @file{/usr/local} directory tree.  Builtin tests avoid
1549 running @code{file} on files that are not regular files or are not
1550 executable.
1552 @example
1553 find /usr/local -type f -perm +a=x | xargs file | 
1554   grep 'not stripped' | cut -d: -f1
1555 @end example
1557 @noindent
1558 The @code{cut} program removes everything after the file name from the
1559 output of @code{file}.
1561 @c Idea from Martin Weitzel.
1562 If you want to place a special test somewhere in the middle of a
1563 @code{find} expression, you can use @samp{-exec} to run a program that
1564 performs the test.  Because @samp{-exec} evaluates to the exit status of
1565 the executed program, you can write a program (which can be a shell
1566 script) that tests for a special attribute and make it exit with a true
1567 (zero) or false (non-zero) status.  It is a good idea to place such a
1568 special test @emph{after} the builtin tests, because it starts a new
1569 process which could be avoided if a builtin test evaluates to false.
1570 Use this method only when @code{xargs} is not flexible enough, because
1571 starting one or more new processes to test each file is slower than
1572 using @code{xargs} to start one process that tests many files.
1574 Here is a shell script called @code{unstripped} that checks whether its
1575 argument is an unstripped binary file:
1577 @example
1578 #!/bin/sh
1579 file $1 | grep 'not stripped' > /dev/null
1580 @end example
1582 This script relies on the fact that the shell exits with the status of
1583 the last program it executed, in this case @code{grep}.  @code{grep}
1584 exits with a true status if it found any matches, false if not.  Here is
1585 an example of using the script (assuming it is in your search path).  It
1586 lists the stripped executables in the file @file{sbins} and the
1587 unstripped ones in @file{ubins}.
1589 @example
1590 find /usr/local -type f -perm +a=x \
1591   \( -exec unstripped '@{@}' \; -fprint ubins -o -fprint sbins \)
1592 @end example
1594 @node Common Tasks, Databases, Actions, Top
1595 @chapter Common Tasks
1597 The sections that follow contain some extended examples that both give a
1598 good idea of the power of these programs, and show you how to solve
1599 common real-world problems.
1601 @menu
1602 * Viewing And Editing::
1603 * Archiving::
1604 * Cleaning Up::
1605 * Strange File Names::
1606 * Fixing Permissions::
1607 * Classifying Files::
1608 @end menu
1610 @node Viewing And Editing
1611 @section Viewing And Editing
1613 To view a list of files that meet certain criteria, simply run your file
1614 viewing program with the file names as arguments.  Shells substitute a
1615 command enclosed in backquotes with its output, so the whole command
1616 looks like this:
1618 @example
1619 less `find /usr/include -name '*.h' | xargs grep -l mode_t`
1620 @end example
1622 @noindent
1623 You can edit those files by giving an editor name instead of a file
1624 viewing program.
1626 @node Archiving
1627 @section Archiving
1629 You can pass a list of files produced by @code{find} to a file archiving
1630 program.  GNU @code{tar} and @code{cpio} can both read lists of file
1631 names from the standard input---either delimited by nulls (the safe way)
1632 or by blanks (the lazy, risky default way).  To use null-delimited
1633 names, give them the @samp{--null} option.  You can store a file archive
1634 in a file, write it on a tape, or send it over a network to extract on
1635 another machine.
1637 One common use of @code{find} to archive files is to send a list of the
1638 files in a directory tree to @code{cpio}.  Use @samp{-depth} so if a
1639 directory does not have write permission for its owner, its contents can
1640 still be restored from the archive since the directory's permissions are
1641 restored after its contents.  Here is an example of doing this using
1642 @code{cpio}; you could use a more complex @code{find} expression to
1643 archive only certain files.
1645 @example
1646 find . -depth -print0 |
1647   cpio --create --null --format=crc --file=/dev/nrst0
1648 @end example
1650 You could restore that archive using this command:
1652 @example
1653 cpio --extract --null --make-dir --unconditional \
1654   --preserve --file=/dev/nrst0
1655 @end example
1657 Here are the commands to do the same things using @code{tar}:
1659 @example
1660 find . -depth -print0 |
1661   tar --create --null --files-from=- --file=/dev/nrst0
1663 tar --extract --null --preserve-perm --same-owner \
1664   --file=/dev/nrst0
1665 @end example
1667 @c Idea from Rick Sladkey.
1668 Here is an example of copying a directory from one machine to another:
1670 @example
1671 find . -depth -print0 | cpio -0o -Hnewc |
1672   rsh @var{other-machine} "cd `pwd` && cpio -i0dum"
1673 @end example
1675 @node Cleaning Up
1676 @section Cleaning Up
1678 @c Idea from Jim Meyering.
1679 This section gives examples of removing unwanted files in various situations.
1680 Here is a command to remove the CVS backup files created when an update
1681 requires a merge:
1683 @example
1684 find . -name '.#*' -print0 | xargs -0r rm -f
1685 @end example
1687 @c Idea from Franc,ois Pinard.
1688 You can run this command to clean out your clutter in @file{/tmp}.  You
1689 might place it in the file your shell runs when you log out
1690 (@file{.bash_logout}, @file{.logout}, or @file{.zlogout}, depending on
1691 which shell you use).
1693 @example
1694 find /tmp -user $LOGNAME -type f -print0 | xargs -0 -r rm -f
1695 @end example
1697 @c Idea from Noah Friedman.
1698 To remove old Emacs backup and auto-save files, you can use a command
1699 like the following.  It is especially important in this case to use
1700 null-terminated file names because Emacs packages like the VM mailer
1701 often create temporary file names with spaces in them, like @file{#reply
1702 to David J. MacKenzie<1>#}.
1704 @example
1705 find ~ \( -name '*~' -o -name '#*#' \) -print0 |
1706   xargs --no-run-if-empty --null rm -vf
1707 @end example
1709 Removing old files from @file{/tmp} is commonly done from @code{cron}:
1711 @c Idea from Kaveh Ghazi.
1712 @example
1713 find /tmp /var/tmp -not -type d -mtime +3 -print0 |
1714   xargs --null --no-run-if-empty rm -f
1716 find /tmp /var/tmp -depth -mindepth 1 -type d -empty -print0 |
1717   xargs --null --no-run-if-empty rmdir
1718 @end example
1720 The second @code{find} command above uses @samp{-depth} so it cleans out
1721 empty directories depth-first, hoping that the parents become empty and
1722 can be removed too.  It uses @samp{-mindepth} to avoid removing
1723 @file{/tmp} itself if it becomes totally empty.
1725 @node Strange File Names
1726 @section Strange File Names
1728 @c Idea from:
1729 @c From: tmatimar@isgtec.com (Ted Timar)
1730 @c Newsgroups: comp.unix.questions,comp.unix.shell,comp.answers,news.answers
1731 @c Subject: Unix - Frequently Asked Questions (2/7) [Frequent posting]
1732 @c Subject: How do I remove a file with funny characters in the filename ?
1733 @c Date: Thu Mar 18 17:16:55 EST 1993
1734 @code{find} can help you remove or rename a file with strange characters
1735 in its name.  People are sometimes stymied by files whose names contain
1736 characters such as spaces, tabs, control characters, or characters with
1737 the high bit set.  The simplest way to remove such files is:
1739 @example
1740 rm -i @var{some*pattern*that*matches*the*problem*file}
1741 @end example
1743 @code{rm} asks you whether to remove each file matching the given
1744 pattern.  If you are using an old shell, this approach might not work if
1745 the file name contains a character with the high bit set; the shell may
1746 strip it off.  A more reliable way is:
1748 @example
1749 find . -maxdepth 1 @var{tests} -ok rm '@{@}' \;
1750 @end example
1752 @noindent
1753 where @var{tests} uniquely identify the file.  The @samp{-maxdepth 1}
1754 option prevents @code{find} from wasting time searching for the file in
1755 any subdirectories; if there are no subdirectories, you may omit it.  A
1756 good way to uniquely identify the problem file is to figure out its
1757 inode number; use
1759 @example
1760 ls -i
1761 @end example
1763 Suppose you have a file whose name contains control characters, and you
1764 have found that its inode number is 12345.  This command prompts you for
1765 whether to remove it:
1767 @example
1768 find . -maxdepth 1 -inum 12345 -ok rm -f '@{@}' \;
1769 @end example
1771 If you don't want to be asked, perhaps because the file name may contain
1772 a strange character sequence that will mess up your screen when printed,
1773 then use @samp{-exec} instead of @samp{-ok}.
1775 If you want to rename the file instead, you can use @code{mv} instead of
1776 @code{rm}:
1778 @example
1779 find . -maxdepth 1 -inum 12345 -ok mv '@{@}' @var{new-file-name} \;
1780 @end example
1782 @node Fixing Permissions
1783 @section Fixing Permissions
1785 Suppose you want to make sure that everyone can write to the directories in a
1786 certain directory tree.  Here is a way to find directories lacking either
1787 user or group write permission (or both), and fix their permissions:
1789 @example
1790 find . -type d -not -perm -ug=w | xargs chmod ug+w
1791 @end example
1793 @noindent
1794 You could also reverse the operations, if you want to make sure that
1795 directories do @emph{not} have world write permission.
1797 @node Classifying Files
1798 @section Classifying Files
1800 @c Idea from:
1801 @c From: martin@mwtech.UUCP (Martin Weitzel)
1802 @c Newsgroups: comp.unix.wizards,comp.unix.questions
1803 @c Subject: Advanced usage of 'find' (Re: Unix security automating script)
1804 @c Date: 22 Mar 90 15:05:19 GMT
1805 If you want to classify a set of files into several groups based on
1806 different criteria, you can use the comma operator to perform multiple
1807 independent tests on the files.  Here is an example:
1809 @example
1810 find / -type d \( -perm -o=w -fprint allwrite , \
1811   -perm -o=x -fprint allexec \)
1813 echo "Directories that can be written to by everyone:"
1814 cat allwrite
1815 echo ""
1816 echo "Directories with search permissions for everyone:"
1817 cat allexec
1818 @end example
1820 @code{find} has only to make one scan through the directory tree (which
1821 is one of the most time consuming parts of its work).
1823 @node Databases, File Permissions, Common Tasks, Top
1824 @chapter File Name Databases
1826 The file name databases used by @code{locate} contain lists of files
1827 that were in particular directory trees when the databases were last
1828 updated.  The file name of the default database is determined when
1829 @code{locate} and @code{updatedb} are configured and installed.  The
1830 frequency with which the databases are updated and the directories for
1831 which they contain entries depend on how often @code{updatedb} is run,
1832 and with which arguments.
1834 @menu
1835 * Database Locations::
1836 * Database Formats::
1837 @end menu
1839 @node Database Locations
1840 @section Database Locations
1842 There can be multiple file name databases.  Users can select which
1843 databases @code{locate} searches using an environment variable or a
1844 command line option.  The system administrator can choose the file name
1845 of the default database, the frequency with which the databases are
1846 updated, and the directories for which they contain entries.  File name
1847 databases are updated by running the @code{updatedb} program, typically
1848 nightly.
1850 In networked environments, it often makes sense to build a database at
1851 the root of each filesystem, containing the entries for that filesystem.
1852 @code{updatedb} is then run for each filesystem on the fileserver where
1853 that filesystem is on a local disk, to prevent thrashing the network.
1854 Here are the options to @code{updatedb} to select which directories each
1855 database contains entries for:
1857 @table @code
1858 @item --localpaths='@var{path}@dots{}'
1859 Non-network directories to put in the database.
1860 Default is @file{/}.
1862 @item --netpaths='@var{path}@dots{}'
1863 Network (NFS, AFS, RFS, etc.) directories to put in the database.
1864 Default is none.
1866 @item --prunepaths='@var{path}@dots{}'
1867 Directories to not put in the database, which would otherwise be.
1868 Default is @file{/tmp /usr/tmp /var/tmp /afs}.
1870 @item --output=@var{dbfile}
1871 The database file to build.
1872 Default is system-dependent, but typically @file{/usr/local/var/locatedb}.
1874 @item --netuser=@var{user}
1875 The user to search network directories as, using @code{su}.
1876 Default is @code{daemon}.
1877 @end table
1879 @node Database Formats
1880 @section Database Formats
1882 The file name databases contain lists of files that were in particular
1883 directory trees when the databases were last updated.  The file name
1884 database format changed starting with GNU @code{locate} version 4.0 to
1885 allow machines with diffent byte orderings to share the databases.  The
1886 new GNU @code{locate} can read both the old and new database formats.
1887 However, old versions of @code{locate} and @code{find} produce incorrect
1888 results if given a new-format database.
1890 @menu
1891 * New Database Format::
1892 * Sample Database::
1893 * Old Database Format::
1894 @end menu
1896 @node New Database Format
1897 @subsection New Database Format
1899 @code{updatedb} runs a program called @code{frcode} to
1900 @dfn{front-compress} the list of file names, which reduces the database
1901 size by a factor of 4 to 5.  Front-compression (also known as
1902 incremental encoding) works as follows.
1904 The database entries are a sorted list (case-insensitively, for users'
1905 convenience).  Since the list is sorted, each entry is likely to share a
1906 prefix (initial string) with the previous entry.  Each database entry
1907 begins with an offset-differential count byte, which is the additional
1908 number of characters of prefix of the preceding entry to use beyond the
1909 number that the preceding entry is using of its predecessor.  (The
1910 counts can be negative.)  Following the count is a null-terminated ASCII
1911 remainder---the part of the name that follows the shared prefix.
1913 If the offset-differential count is larger than can be stored in a byte
1914 (+/-127), the byte has the value 0x80 and the count follows in a 2-byte
1915 word, with the high byte first (network byte order).
1917 Every database begins with a dummy entry for a file called
1918 @file{LOCATE02}, which @code{locate} checks for to ensure that the
1919 database file has the correct format; it ignores the entry in doing the
1920 search.
1922 Databases can not be concatenated together, even if the first (dummy)
1923 entry is trimmed from all but the first database.  This is because the
1924 offset-differential count in the first entry of the second and following
1925 databases will be wrong.
1927 @node Sample Database
1928 @subsection Sample Database
1930 Sample input to @code{frcode}:
1931 @c with nulls changed to newlines:
1933 @example
1934 /usr/src
1935 /usr/src/cmd/aardvark.c
1936 /usr/src/cmd/armadillo.c
1937 /usr/tmp/zoo
1938 @end example
1940 Length of the longest prefix of the preceding entry to share:
1942 @example
1943 0 /usr/src
1944 8 /cmd/aardvark.c
1945 14 rmadillo.c
1946 5 tmp/zoo
1947 @end example
1949 Output from @code{frcode}, with trailing nulls changed to newlines
1950 and count bytes made printable:
1952 @example
1953 0 LOCATE02
1954 0 /usr/src
1955 8 /cmd/aardvark.c
1956 6 rmadillo.c
1957 -9 tmp/zoo
1958 @end example
1960 (6 = 14 - 8, and -9 = 5 - 14)
1962 @node Old Database Format
1963 @subsection Old Database Format
1965 The old database format is used by Unix @code{locate} and @code{find}
1966 programs and earlier releases of the GNU ones.  @code{updatedb} produces
1967 this format if given the @samp{--old-format} option.
1969 @code{updatedb} runs programs called @code{bigram} and @code{code} to
1970 produce old-format databases.  The old format differs from the new one
1971 in the following ways.  Instead of each entry starting with an
1972 offset-differential count byte and ending with a null, byte values from
1973 0 through 28 indicate offset-differential counts from -14 through 14.
1974 The byte value indicating that a long offset-differential count follows
1975 is 0x1e (30), not 0x80.  The long counts are stored in host byte order,
1976 which is not necessarily network byte order, and host integer word size,
1977 which is usually 4 bytes.  They also represent a count 14 less than
1978 their value.  The database lines have no termination byte; the start of
1979 the next line is indicated by its first byte having a value <= 30.
1981 In addition, instead of starting with a dummy entry, the old database
1982 format starts with a 256 byte table containing the 128 most common
1983 bigrams in the file list.  A bigram is a pair of adjacent bytes.  Bytes
1984 in the database that have the high bit set are indexes (with the high
1985 bit cleared) into the bigram table.  The bigram and offset-differential
1986 count coding makes these databases 20-25% smaller than the new format,
1987 but makes them not 8-bit clean.  Any byte in a file name that is in the
1988 ranges used for the special codes is replaced in the database by a
1989 question mark, which not coincidentally is the shell wildcard to match a
1990 single character.
1992 @node File Permissions, Reference, Databases, Top
1993 @chapter File Permissions
1995 @include perm.texi
1997 @node Reference, Primary Index, File Permissions, Top
1998 @chapter Reference
2000 Below are summaries of the command line syntax for the programs
2001 discussed in this manual.
2003 @menu
2004 * Invoking find::
2005 * Invoking locate::
2006 * Invoking updatedb::
2007 * Invoking xargs::
2008 @end menu
2010 @node Invoking find, Invoking locate, , Reference
2011 @section Invoking @code{find}
2013 @example
2014 find @r{[}@var{file}@dots{}@r{]} @r{[}@var{expression}@r{]}
2015 @end example
2017 @code{find} searches the directory tree rooted at each file name
2018 @var{file} by evaluating the @var{expression} on each file it finds in
2019 the tree.
2021 @code{find} considers the first argument that begins with @samp{-},
2022 @samp{(}, @samp{)}, @samp{,}, or @samp{!} to be the beginning of the
2023 expression; any arguments before it are paths to search, and any
2024 arguments after it are the rest of the expression.  If no paths are
2025 given, the current directory is used.  If no expression is given, the
2026 expression @samp{-print} is used.
2028 @code{find} exits with status 0 if all files are processed successfully,
2029 greater than 0 if errors occur.
2031 @xref{Primary Index}, for a summary of all of the tests, actions, and
2032 options that the expression can contain.
2034 @code{find} also recognizes two options for administrative use:
2036 @table @code
2037 @item --help
2038 Print a summary of the command-line argument format and exit.
2039 @item --version
2040 Print the version number of @code{find} and exit.
2041 @end table
2043 @node Invoking locate, Invoking updatedb, Invoking find, Reference
2044 @section Invoking @code{locate}
2046 @example
2047 locate @r{[}@var{option}@dots{}@r{]} @var{pattern}@dots{}
2048 @end example
2050 @table @code
2051 @item --database=@var{path}
2052 @itemx -d @var{path}
2053 Instead of searching the default file name database, search the file
2054 name databases in @var{path}, which is a colon-separated list of
2055 database file names.  You can also use the environment variable
2056 @code{LOCATE_PATH} to set the list of database files to search.  The
2057 option overrides the environment variable if both are used.
2059 @item --help
2060 Print a summary of the options to @code{locate} and exit.
2062 @item --version
2063 Print the version number of @code{locate} and exit.
2064 @end table
2066 @node Invoking updatedb, Invoking xargs, Invoking locate, Reference
2067 @section Invoking @code{updatedb}
2069 @example
2070 updatedb @r{[}@var{option}@dots{}@r{]}
2071 @end example
2073 @table @code
2074 @item --localpaths='@var{path}@dots{}'
2075 Non-network directories to put in the database.
2076 Default is @file{/}.
2078 @item --netpaths='@var{path}@dots{}'
2079 Network (NFS, AFS, RFS, etc.) directories to put in the database.
2080 Default is none.
2082 @item --prunepaths='@var{path}@dots{}'
2083 Directories to not put in the database, which would otherwise be.
2084 Default is @file{/tmp /usr/tmp /var/tmp /afs}.
2086 @item --output=@var{dbfile}
2087 The database file to build.
2088 Default is system-dependent, but typically @file{/usr/local/var/locatedb}.
2090 @item --netuser=@var{user}
2091 The user to search network directories as, using @code{su}(1).
2092 Default is @code{daemon}.
2093 @end table
2095 @node Invoking xargs, ,  Invoking updatedb, Reference
2096 @section Invoking @code{xargs}
2098 @example
2099 xargs @r{[}@var{option}@dots{}@r{]} @r{[}@var{command} @r{[}@var{initial-arguments}@r{]}@r{]}
2100 @end example
2102 @code{xargs} exits with the following status:
2104 @table @asis
2105 @item 0
2106 if it succeeds
2107 @item 123
2108 if any invocation of the command exited with status 1-125
2109 @item 124
2110 if the command exited with status 255
2111 @item 125
2112 if the command is killed by a signal
2113 @item 126
2114 if the command cannot be run
2115 @item 127
2116 if the command is not found
2117 @item 1
2118 if some other error occurred.
2119 @end table
2121 @table @code
2122 @item --null
2123 @itemx -0
2124 Input filenames are terminated by a null character instead of by
2125 whitespace, and the quotes and backslash are not special (every
2126 character is taken literally).  Disables the end of file string, which
2127 is treated like any other argument.
2129 @item --eof@r{[}=@var{eof-str}@r{]}
2130 @itemx -e@r{[}@var{eof-str}@r{]}
2131 Set the end of file string to @var{eof-str}.  If the end of file string
2132 occurs as a line of input, the rest of the input is ignored.  If
2133 @var{eof-str} is omitted, there is no end of file string.  If this
2134 option is not given, the end of file string defaults to @samp{_}.
2136 @item --help
2137 Print a summary of the options to @code{xargs} and exit.
2139 @item --replace@r{[}=@var{replace-str}@r{]}
2140 @itemx -i@r{[}@var{replace-str}@r{]}
2141 Replace occurences of @var{replace-str} in the initial arguments with
2142 names read from standard input.  Also, unquoted blanks do not terminate
2143 arguments.  If @var{replace-str} is omitted, it defaults to @samp{@{@}}
2144 (like for @samp{find -exec}).  Implies @samp{-x} and @samp{-l 1}.
2146 @item --max-lines@r{[}=@var{max-lines}@r{]}
2147 @itemx -l@r{[}@var{max-lines}@r{]}
2148 Use at most @var{max-lines} nonblank input lines per command line;
2149 @var{max-lines} defaults to 1 if omitted.  Trailing blanks cause an
2150 input line to be logically continued on the next input line, for the
2151 purpose of counting the lines.  Implies @samp{-x}.
2153 @item --max-args=@var{max-args}
2154 @itemx -n @var{max-args}
2155 Use at most @var{max-args} arguments per command line.  Fewer than
2156 @var{max-args} arguments will be used if the size (see the @samp{-s}
2157 option) is exceeded, unless the @samp{-x} option is given, in which case
2158 @code{xargs} will exit.
2160 @item --interactive
2161 @itemx -p
2162 Prompt the user about whether to run each command line and read a line
2163 from the terminal.  Only run the command line if the response starts
2164 with @samp{y} or @samp{Y}.  Implies @samp{-t}.
2166 @item --no-run-if-empty
2167 @itemx -r
2168 If the standard input does not contain any nonblanks, do not run the
2169 command.  By default, the command is run once even if there is no input.
2171 @item --max-chars=@var{max-chars}
2172 @itemx -s @var{max-chars}
2173 Use at most @var{max-chars} characters per command line, including the
2174 command and initial arguments and the terminating nulls at the ends of
2175 the argument strings.
2177 @item --verbose
2178 @itemx -t
2179 Print the command line on the standard error output before executing
2182 @item --version
2183 Print the version number of @code{xargs} and exit.
2185 @item --exit
2186 @itemx -x
2187 Exit if the size (see the @var{-s} option) is exceeded.
2189 @item --max-procs=@var{max-procs}
2190 @itemx -P @var{max-procs}
2191 Run up to @var{max-procs} processes at a time; the default is 1.  If
2192 @var{max-procs} is 0, @code{xargs} will run as many processes as
2193 possible at a time.
2194 @end table
2196 @node Primary Index, , Reference, Top
2197 @unnumbered @code{find} Primary Index
2199 This is a list of all of the primaries (tests, actions, and options)
2200 that make up @code{find} expressions for selecting files.  @xref{find
2201 Expressions}, for more information on expressions.
2203 @printindex fn
2205 @contents
2206 @bye