* README-alpha: added alpha README file
[findutils.git] / doc / find.info-2
blob6a9f8dbc0e4cb82277ccee8b49943761d289bc5d
1 This is Info file find.info, produced by Makeinfo version 1.68 from the
2 input file find.texi.
4 START-INFO-DIR-ENTRY
5 * Finding Files: (find).        Listing and operating on files
6                                 that match certain criteria.
7 END-INFO-DIR-ENTRY
9    This file documents the GNU utilities for finding files that match
10 certain criteria and performing various operations on them.
12    Copyright (C) 1994 Free Software Foundation, Inc.
14    Permission is granted to make and distribute verbatim copies of this
15 manual provided the copyright notice and this permission notice are
16 preserved on all copies.
18    Permission is granted to copy and distribute modified versions of
19 this manual under the conditions for verbatim copying, provided that
20 the entire resulting derived work is distributed under the terms of a
21 permission notice identical to this one.
23    Permission is granted to copy and distribute translations of this
24 manual into another language, under the above conditions for modified
25 versions, except that this permission notice may be stated in a
26 translation approved by the Foundation.
28 \x1f
29 File: find.info,  Node: Viewing And Editing,  Next: Archiving,  Up: Common Tasks
31 Viewing And Editing
32 ===================
34    To view a list of files that meet certain criteria, simply run your
35 file viewing program with the file names as arguments.  Shells
36 substitute a command enclosed in backquotes with its output, so the
37 whole command looks like this:
39      less `find /usr/include -name '*.h' | xargs grep -l mode_t`
41 You can edit those files by giving an editor name instead of a file
42 viewing program.
44 \x1f
45 File: find.info,  Node: Archiving,  Next: Cleaning Up,  Prev: Viewing And Editing,  Up: Common Tasks
47 Archiving
48 =========
50    You can pass a list of files produced by `find' to a file archiving
51 program.  GNU `tar' and `cpio' can both read lists of file names from
52 the standard input--either delimited by nulls (the safe way) or by
53 blanks (the lazy, risky default way).  To use null-delimited names,
54 give them the `--null' option.  You can store a file archive in a file,
55 write it on a tape, or send it over a network to extract on another
56 machine.
58    One common use of `find' to archive files is to send a list of the
59 files in a directory tree to `cpio'.  Use `-depth' so if a directory
60 does not have write permission for its owner, its contents can still be
61 restored from the archive since the directory's permissions are
62 restored after its contents.  Here is an example of doing this using
63 `cpio'; you could use a more complex `find' expression to archive only
64 certain files.
66      find . -depth -print0 |
67        cpio --create --null --format=crc --file=/dev/nrst0
69    You could restore that archive using this command:
71      cpio --extract --null --make-dir --unconditional \
72        --preserve --file=/dev/nrst0
74    Here are the commands to do the same things using `tar':
76      find . -depth -print0 |
77        tar --create --null --files-from=- --file=/dev/nrst0
78      
79      tar --extract --null --preserve-perm --same-owner \
80        --file=/dev/nrst0
82    Here is an example of copying a directory from one machine to
83 another:
85      find . -depth -print0 | cpio -0o -Hnewc |
86        rsh OTHER-MACHINE "cd `pwd` && cpio -i0dum"
88 \x1f
89 File: find.info,  Node: Cleaning Up,  Next: Strange File Names,  Prev: Archiving,  Up: Common Tasks
91 Cleaning Up
92 ===========
94    This section gives examples of removing unwanted files in various
95 situations.  Here is a command to remove the CVS backup files created
96 when an update requires a merge:
98      find . -name '.#*' -print0 | xargs -0r rm -f
100    You can run this command to clean out your clutter in `/tmp'.  You
101 might place it in the file your shell runs when you log out
102 (`.bash_logout', `.logout', or `.zlogout', depending on which shell you
103 use).
105      find /tmp -user $LOGNAME -type f -print0 | xargs -0 -r rm -f
107    To remove old Emacs backup and auto-save files, you can use a command
108 like the following.  It is especially important in this case to use
109 null-terminated file names because Emacs packages like the VM mailer
110 often create temporary file names with spaces in them, like `#reply to
111 David J. MacKenzie<1>#'.
113      find ~ \( -name '*~' -o -name '#*#' \) -print0 |
114        xargs --no-run-if-empty --null rm -vf
116    Removing old files from `/tmp' is commonly done from `cron':
118      find /tmp /var/tmp -not -type d -mtime +3 -print0 |
119        xargs --null --no-run-if-empty rm -f
120      
121      find /tmp /var/tmp -depth -mindepth 1 -type d -empty -print0 |
122        xargs --null --no-run-if-empty rmdir
124    The second `find' command above uses `-depth' so it cleans out empty
125 directories depth-first, hoping that the parents become empty and can
126 be removed too.  It uses `-mindepth' to avoid removing `/tmp' itself if
127 it becomes totally empty.
129 \x1f
130 File: find.info,  Node: Strange File Names,  Next: Fixing Permissions,  Prev: Cleaning Up,  Up: Common Tasks
132 Strange File Names
133 ==================
135    `find' can help you remove or rename a file with strange characters
136 in its name.  People are sometimes stymied by files whose names contain
137 characters such as spaces, tabs, control characters, or characters with
138 the high bit set.  The simplest way to remove such files is:
140      rm -i SOME*PATTERN*THAT*MATCHES*THE*PROBLEM*FILE
142    `rm' asks you whether to remove each file matching the given
143 pattern.  If you are using an old shell, this approach might not work if
144 the file name contains a character with the high bit set; the shell may
145 strip it off.  A more reliable way is:
147      find . -maxdepth 1 TESTS -ok rm '{}' \;
149 where TESTS uniquely identify the file.  The `-maxdepth 1' option
150 prevents `find' from wasting time searching for the file in any
151 subdirectories; if there are no subdirectories, you may omit it.  A
152 good way to uniquely identify the problem file is to figure out its
153 inode number; use
155      ls -i
157    Suppose you have a file whose name contains control characters, and
158 you have found that its inode number is 12345.  This command prompts
159 you for whether to remove it:
161      find . -maxdepth 1 -inum 12345 -ok rm -f '{}' \;
163    If you don't want to be asked, perhaps because the file name may
164 contain a strange character sequence that will mess up your screen when
165 printed, then use `-exec' instead of `-ok'.
167    If you want to rename the file instead, you can use `mv' instead of
168 `rm':
170      find . -maxdepth 1 -inum 12345 -ok mv '{}' NEW-FILE-NAME \;
172 \x1f
173 File: find.info,  Node: Fixing Permissions,  Next: Classifying Files,  Prev: Strange File Names,  Up: Common Tasks
175 Fixing Permissions
176 ==================
178    Suppose you want to make sure that everyone can write to the
179 directories in a certain directory tree.  Here is a way to find
180 directories lacking either user or group write permission (or both),
181 and fix their permissions:
183      find . -type d -not -perm -ug=w | xargs chmod ug+w
185 You could also reverse the operations, if you want to make sure that
186 directories do *not* have world write permission.
188 \x1f
189 File: find.info,  Node: Classifying Files,  Prev: Fixing Permissions,  Up: Common Tasks
191 Classifying Files
192 =================
194    If you want to classify a set of files into several groups based on
195 different criteria, you can use the comma operator to perform multiple
196 independent tests on the files.  Here is an example:
198      find / -type d \( -perm -o=w -fprint allwrite , \
199        -perm -o=x -fprint allexec \)
200      
201      echo "Directories that can be written to by everyone:"
202      cat allwrite
203      echo ""
204      echo "Directories with search permissions for everyone:"
205      cat allexec
207    `find' has only to make one scan through the directory tree (which
208 is one of the most time consuming parts of its work).
210 \x1f
211 File: find.info,  Node: Databases,  Next: File Permissions,  Prev: Common Tasks,  Up: Top
213 File Name Databases
214 *******************
216    The file name databases used by `locate' contain lists of files that
217 were in particular directory trees when the databases were last
218 updated.  The file name of the default database is determined when
219 `locate' and `updatedb' are configured and installed.  The frequency
220 with which the databases are updated and the directories for which they
221 contain entries depend on how often `updatedb' is run, and with which
222 arguments.
224 * Menu:
226 * Database Locations::
227 * Database Formats::
229 \x1f
230 File: find.info,  Node: Database Locations,  Next: Database Formats,  Up: Databases
232 Database Locations
233 ==================
235    There can be multiple file name databases.  Users can select which
236 databases `locate' searches using an environment variable or a command
237 line option.  The system administrator can choose the file name of the
238 default database, the frequency with which the databases are updated,
239 and the directories for which they contain entries.  File name
240 databases are updated by running the `updatedb' program, typically
241 nightly.
243    In networked environments, it often makes sense to build a database
244 at the root of each filesystem, containing the entries for that
245 filesystem.  `updatedb' is then run for each filesystem on the
246 fileserver where that filesystem is on a local disk, to prevent
247 thrashing the network.  Here are the options to `updatedb' to select
248 which directories each database contains entries for:
250 `--localpaths='PATH...''
251      Non-network directories to put in the database.  Default is `/'.
253 `--netpaths='PATH...''
254      Network (NFS, AFS, RFS, etc.) directories to put in the database.
255      The environment variable `NETPATHS' also sets this value.  Default
256      is none.
258 `--prunepaths='PATH...''
259      Directories to not put in the database, which would otherwise be.
260      The environment variable `PRUNEPATHS' also sets this value.
261      Default is `/tmp /usr/tmp /var/tmp /afs'.
263 `--prunefs='PATH...''
264      File systems to not put in the database, which would otherwise be.
265      Note that files are pruned when a file system is reached; Any file
266      system mounted under an undesired file system will be ignored.
267      The environment variable `PRUNEFS' also sets this value.  Default
268      is `nfs NFS proc'.
270 `--output=DBFILE'
271      The database file to build.  Default is system-dependent, but
272      typically `/usr/local/var/locatedb'.
274 `--localuser=USER'
275      The user to search the non-network directories as, using `su'.
276      Default is to search the non-network directories as the current
277      user.  You can also use the environment variable `LOCALUSER' to
278      set this user.
280 `--netuser=USER'
281      The user to search network directories as, using `su'.  Default is
282      `daemon'.  You can also use the environment variable `NETUSER' to
283      set this user.
285 \x1f
286 File: find.info,  Node: Database Formats,  Prev: Database Locations,  Up: Databases
288 Database Formats
289 ================
291    The file name databases contain lists of files that were in
292 particular directory trees when the databases were last updated.  The
293 file name database format changed starting with GNU `locate' version
294 4.0 to allow machines with diffent byte orderings to share the
295 databases.  The new GNU `locate' can read both the old and new database
296 formats.  However, old versions of `locate' and `find' produce incorrect
297 results if given a new-format database.
299 * Menu:
301 * New Database Format::
302 * Sample Database::
303 * Old Database Format::
305 \x1f
306 File: find.info,  Node: New Database Format,  Next: Sample Database,  Up: Database Formats
308 New Database Format
309 -------------------
311    `updatedb' runs a program called `frcode' to "front-compress" the
312 list of file names, which reduces the database size by a factor of 4 to
313 5.  Front-compression (also known as incremental encoding) works as
314 follows.
316    The database entries are a sorted list (case-insensitively, for
317 users' convenience).  Since the list is sorted, each entry is likely to
318 share a prefix (initial string) with the previous entry.  Each database
319 entry begins with an offset-differential count byte, which is the
320 additional number of characters of prefix of the preceding entry to use
321 beyond the number that the preceding entry is using of its predecessor.
322 (The counts can be negative.)  Following the count is a
323 null-terminated ASCII remainder--the part of the name that follows the
324 shared prefix.
326    If the offset-differential count is larger than can be stored in a
327 byte (+/-127), the byte has the value 0x80 and the count follows in a
328 2-byte word, with the high byte first (network byte order).
330    Every database begins with a dummy entry for a file called
331 `LOCATE02', which `locate' checks for to ensure that the database file
332 has the correct format; it ignores the entry in doing the search.
334    Databases can not be concatenated together, even if the first (dummy)
335 entry is trimmed from all but the first database.  This is because the
336 offset-differential count in the first entry of the second and following
337 databases will be wrong.
339 \x1f
340 File: find.info,  Node: Sample Database,  Next: Old Database Format,  Prev: New Database Format,  Up: Database Formats
342 Sample Database
343 ---------------
345    Sample input to `frcode':
347      /usr/src
348      /usr/src/cmd/aardvark.c
349      /usr/src/cmd/armadillo.c
350      /usr/tmp/zoo
352    Length of the longest prefix of the preceding entry to share:
354      0 /usr/src
355      8 /cmd/aardvark.c
356      14 rmadillo.c
357      5 tmp/zoo
359    Output from `frcode', with trailing nulls changed to newlines and
360 count bytes made printable:
362      0 LOCATE02
363      0 /usr/src
364      8 /cmd/aardvark.c
365      6 rmadillo.c
366      -9 tmp/zoo
368    (6 = 14 - 8, and -9 = 5 - 14)
370 \x1f
371 File: find.info,  Node: Old Database Format,  Prev: Sample Database,  Up: Database Formats
373 Old Database Format
374 -------------------
376    The old database format is used by Unix `locate' and `find' programs
377 and earlier releases of the GNU ones.  `updatedb' produces this format
378 if given the `--old-format' option.
380    `updatedb' runs programs called `bigram' and `code' to produce
381 old-format databases.  The old format differs from the new one in the
382 following ways.  Instead of each entry starting with an
383 offset-differential count byte and ending with a null, byte values from
384 0 through 28 indicate offset-differential counts from -14 through 14.
385 The byte value indicating that a long offset-differential count follows
386 is 0x1e (30), not 0x80.  The long counts are stored in host byte order,
387 which is not necessarily network byte order, and host integer word size,
388 which is usually 4 bytes.  They also represent a count 14 less than
389 their value.  The database lines have no termination byte; the start of
390 the next line is indicated by its first byte having a value <= 30.
392    In addition, instead of starting with a dummy entry, the old database
393 format starts with a 256 byte table containing the 128 most common
394 bigrams in the file list.  A bigram is a pair of adjacent bytes.  Bytes
395 in the database that have the high bit set are indexes (with the high
396 bit cleared) into the bigram table.  The bigram and offset-differential
397 count coding makes these databases 20-25% smaller than the new format,
398 but makes them not 8-bit clean.  Any byte in a file name that is in the
399 ranges used for the special codes is replaced in the database by a
400 question mark, which not coincidentally is the shell wildcard to match a
401 single character.
403 \x1f
404 File: find.info,  Node: File Permissions,  Next: Reference,  Prev: Databases,  Up: Top
406 File Permissions
407 ****************
409    Each file has a set of "permissions" that control the kinds of
410 access that users have to that file.  The permissions for a file are
411 also called its "access mode".  They can be represented either in
412 symbolic form or as an octal number.
414 * Menu:
416 * Mode Structure::              Structure of file permissions.
417 * Symbolic Modes::              Mnemonic permissions representation.
418 * Numeric Modes::               Permissions as octal numbers.
420 \x1f
421 File: find.info,  Node: Mode Structure,  Next: Symbolic Modes,  Up: File Permissions
423 Structure of File Permissions
424 =============================
426    There are three kinds of permissions that a user can have for a file:
428   1. permission to read the file.  For directories, this means
429      permission to list the contents of the directory.
431   2. permission to write to (change) the file.  For directories, this
432      means permission to create and remove files in the directory.
434   3. permission to execute the file (run it as a program).  For
435      directories, this means permission to access files in the
436      directory.
438    There are three categories of users who may have different
439 permissions to perform any of the above operations on a file:
441   1. the file's owner;
443   2. other users who are in the file's group;
445   3. everyone else.
447    Files are given an owner and group when they are created.  Usually
448 the owner is the current user and the group is the group of the
449 directory the file is in, but this varies with the operating system, the
450 filesystem the file is created on, and the way the file is created.  You
451 can change the owner and group of a file by using the `chown' and
452 `chgrp' commands.
454    In addition to the three sets of three permissions listed above, a
455 file's permissions have three special components, which affect only
456 executable files (programs) and, on some systems, directories:
458   1. set the process's effective user ID to that of the file upon
459      execution (called the "setuid bit").  No effect on directories.
461   2. set the process's effective group ID to that of the file upon
462      execution (called the "setgid bit").  For directories on some
463      systems, put files created in the directory into the same group as
464      the directory, no matter what group the user who creates them is
465      in.
467   3. save the program's text image on the swap device so it will load
468      more quickly when run (called the "sticky bit").  For directories
469      on some systems, prevent users from removing files that they do
470      not own in the directory; this is called making the directory
471      "append-only".
473 \x1f
474 File: find.info,  Node: Symbolic Modes,  Next: Numeric Modes,  Prev: Mode Structure,  Up: File Permissions
476 Symbolic Modes
477 ==============
479    "Symbolic modes" represent changes to files' permissions as
480 operations on single-character symbols.  They allow you to modify either
481 all or selected parts of files' permissions, optionally based on their
482 previous values, and perhaps on the current `umask' as well (*note
483 Umask and Protection::.).
485    The format of symbolic modes is:
487      [ugoa...][[+-=][rwxXstugo...]...][,...]
489    The following sections describe the operators and other details of
490 symbolic modes.
492 * Menu:
494 * Setting Permissions::          Basic operations on permissions.
495 * Copying Permissions::          Copying existing permissions.
496 * Changing Special Permissions:: Special permissions.
497 * Conditional Executability::    Conditionally affecting executability.
498 * Multiple Changes::             Making multiple changes.
499 * Umask and Protection::              The effect of the umask.
501 \x1f
502 File: find.info,  Node: Setting Permissions,  Next: Copying Permissions,  Up: Symbolic Modes
504 Setting Permissions
505 -------------------
507    The basic symbolic operations on a file's permissions are adding,
508 removing, and setting the permission that certain users have to read,
509 write, and execute the file.  These operations have the following
510 format:
512      USERS OPERATION PERMISSIONS
514 The spaces between the three parts above are shown for readability only;
515 symbolic modes can not contain spaces.
517    The USERS part tells which users' access to the file is changed.  It
518 consists of one or more of the following letters (or it can be empty;
519 *note Umask and Protection::., for a description of what happens then).
520 When more than one of these letters is given, the order that they are
521 in does not matter.
524      the user who owns the file;
527      other users who are in the file's group;
530      all other users;
533      all users; the same as `ugo'.
535    The OPERATION part tells how to change the affected users' access to
536 the file, and is one of the following symbols:
539      to add the PERMISSIONS to whatever permissions the USERS already
540      have for the file;
543      to remove the PERMISSIONS from whatever permissions the USERS
544      already have for the file;
547      to make the PERMISSIONS the only permissions that the USERS have
548      for the file.
550    The PERMISSIONS part tells what kind of access to the file should be
551 changed; it is zero or more of the following letters.  As with the
552 USERS part, the order does not matter when more than one letter is
553 given.  Omitting the PERMISSIONS part is useful only with the `='
554 operation, where it gives the specified USERS no access at all to the
555 file.
558      the permission the USERS have to read the file;
561      the permission the USERS have to write to the file;
564      the permission the USERS have to execute the file.
566    For example, to give everyone permission to read and write a file,
567 but not to execute it, use:
569      a=rw
571    To remove write permission for from all users other than the file's
572 owner, use:
574      go-w
576 The above command does not affect the access that the owner of the file
577 has to it, nor does it affect whether other users can read or execute
578 the file.
580    To give everyone except a file's owner no permission to do anything
581 with that file, use the mode below.  Other users could still remove the
582 file, if they have write permission on the directory it is in.
584      go=
586 Another way to specify the same thing is:
588      og-rxw
590 \x1f
591 File: find.info,  Node: Copying Permissions,  Next: Changing Special Permissions,  Prev: Setting Permissions,  Up: Symbolic Modes
593 Copying Existing Permissions
594 ----------------------------
596    You can base part of a file's permissions on part of its existing
597 permissions.  To do this, instead of using `r', `w', or `x' after the
598 operator, you use the letter `u', `g', or `o'.  For example, the mode
600      o+g
602 adds the permissions for users who are in a file's group to the
603 permissions that other users have for the file.  Thus, if the file
604 started out as mode 664 (`rw-rw-r--'), the above mode would change it
605 to mode 666 (`rw-rw-rw-').  If the file had started out as mode 741
606 (`rwxr----x'), the above mode would change it to mode 745
607 (`rwxr--r-x').  The `-' and `=' operations work analogously.
609 \x1f
610 File: find.info,  Node: Changing Special Permissions,  Next: Conditional Executability,  Prev: Copying Permissions,  Up: Symbolic Modes
612 Changing Special Permissions
613 ----------------------------
615    In addition to changing a file's read, write, and execute
616 permissions, you can change its special permissions.  *Note Mode
617 Structure::, for a summary of these permissions.
619    To change a file's permission to set the user ID on execution, use
620 `u' in the USERS part of the symbolic mode and `s' in the PERMISSIONS
621 part.
623    To change a file's permission to set the group ID on execution, use
624 `g' in the USERS part of the symbolic mode and `s' in the PERMISSIONS
625 part.
627    To change a file's permission to stay permanently on the swap device,
628 use `o' in the USERS part of the symbolic mode and `t' in the
629 PERMISSIONS part.
631    For example, to add set user ID permission to a program, you can use
632 the mode:
634      u+s
636    To remove both set user ID and set group ID permission from it, you
637 can use the mode:
639      ug-s
641    To cause a program to be saved on the swap device, you can use the
642 mode:
644      o+t
646    Remember that the special permissions only affect files that are
647 executable, plus, on some systems, directories (on which they have
648 different meanings; *note Mode Structure::.).  Using `a' in the USERS
649 part of a symbolic mode does not cause the special permissions to be
650 affected; thus,
652      a+s
654 has *no effect*.  You must use `u', `g', and `o' explicitly to affect
655 the special permissions.  Also, the combinations `u+t', `g+t', and
656 `o+s' have no effect.
658    The `=' operator is not very useful with special permissions; for
659 example, the mode:
661      o=t
663 does cause the file to be saved on the swap device, but it also removes
664 all read, write, and execute permissions that users not in the file's
665 group might have had for it.
667 \x1f
668 File: find.info,  Node: Conditional Executability,  Next: Multiple Changes,  Prev: Changing Special Permissions,  Up: Symbolic Modes
670 Conditional Executability
671 -------------------------
673    There is one more special type of symbolic permission: if you use
674 `X' instead of `x', execute permission is affected only if the file
675 already had execute permission or is a directory.  It affects
676 directories' execute permission even if they did not initially have any
677 execute permissions set.
679    For example, this mode:
681      a+X
683 gives all users permission to execute files (or search directories) if
684 anyone could before.
686 \x1f
687 File: find.info,  Node: Multiple Changes,  Next: Umask and Protection,  Prev: Conditional Executability,  Up: Symbolic Modes
689 Making Multiple Changes
690 -----------------------
692    The format of symbolic modes is actually more complex than described
693 above (*note Setting Permissions::.).  It provides two ways to make
694 multiple changes to files' permissions.
696    The first way is to specify multiple OPERATION and PERMISSIONS parts
697 after a USERS part in the symbolic mode.
699    For example, the mode:
701      og+rX-w
703 gives users other than the owner of the file read permission and, if it
704 is a directory or if someone already had execute permission to it,
705 gives them execute permission; and it also denies them write permission
706 to it file.  It does not affect the permission that the owner of the
707 file has for it.  The above mode is equivalent to the two modes:
709      og+rX
710      og-w
712    The second way to make multiple changes is to specify more than one
713 simple symbolic mode, separated by commas.  For example, the mode:
715      a+r,go-w
717 gives everyone permission to read the file and removes write permission
718 on it for all users except its owner.  Another example:
720      u=rwx,g=rx,o=
722 sets all of the non-special permissions for the file explicitly.  (It
723 gives users who are not in the file's group no permission at all for
724 it.)
726    The two methods can be combined.  The mode:
728      a+r,g+x-w
730 gives all users permission to read the file, and gives users who are in
731 the file's group permission to execute it, as well, but not permission
732 to write to it.  The above mode could be written in several different
733 ways; another is:
735      u+r,g+rx,o+r,g-w
737 \x1f
738 File: find.info,  Node: Umask and Protection,  Prev: Multiple Changes,  Up: Symbolic Modes
740 The Umask and Protection
741 ------------------------
743    If the USERS part of a symbolic mode is omitted, it defaults to `a'
744 (affect all users), except that any permissions that are *set* in the
745 system variable `umask' are *not affected*.  The value of `umask' can
746 be set using the `umask' command.  Its default value varies from system
747 to system.
749    Omitting the USERS part of a symbolic mode is generally not useful
750 with operations other than `+'.  It is useful with `+' because it
751 allows you to use `umask' as an easily customizable protection against
752 giving away more permission to files than you intended to.
754    As an example, if `umask' has the value 2, which removes write
755 permission for users who are not in the file's group, then the mode:
757      +w
759 adds permission to write to the file to its owner and to other users who
760 are in the file's group, but *not* to other users.  In contrast, the
761 mode:
763      a+w
765 ignores `umask', and *does* give write permission for the file to all
766 users.
768 \x1f
769 File: find.info,  Node: Numeric Modes,  Prev: Symbolic Modes,  Up: File Permissions
771 Numeric Modes
772 =============
774    File permissions are stored internally as 16 bit integers.  As an
775 alternative to giving a symbolic mode, you can give an octal (base 8)
776 number that corresponds to the internal representation of the new mode.
777 This number is always interpreted in octal; you do not have to add a
778 leading 0, as you do in C.  Mode 0055 is the same as mode 55.
780    A numeric mode is usually shorter than the corresponding symbolic
781 mode, but it is limited in that it can not take into account a file's
782 previous permissions; it can only set them absolutely.
784    The permissions granted to the user, to other users in the file's
785 group, and to other users not in the file's group are each stored as
786 three bits, which are represented as one octal digit.  The three special
787 permissions are also each stored as one bit, and they are as a group
788 represented as another octal digit.  Here is how the bits are arranged
789 in the 16 bit integer, starting with the lowest valued bit:
791      Value in  Corresponding
792      Mode      Permission
793      
794                Other users not in the file's group:
795         1      Execute
796         2      Write
797         4      Read
798      
799                Other users in the file's group:
800        10      Execute
801        20      Write
802        40      Read
803      
804                The file's owner:
805       100      Execute
806       200      Write
807       400      Read
808      
809                Special permissions:
810      1000      Save text image on swap device
811      2000      Set group ID on execution
812      4000      Set user ID on execution
814    For example, numeric mode 4755 corresponds to symbolic mode
815 `u=rwxs,go=rx', and numeric mode 664 corresponds to symbolic mode
816 `ug=rw,o=r'.  Numeric mode 0 corresponds to symbolic mode `ugo='.
818 \x1f
819 File: find.info,  Node: Reference,  Next: Primary Index,  Prev: File Permissions,  Up: Top
821 Reference
822 *********
824    Below are summaries of the command line syntax for the programs
825 discussed in this manual.
827 * Menu:
829 * Invoking find::
830 * Invoking locate::
831 * Invoking updatedb::
832 * Invoking xargs::
834 \x1f
835 File: find.info,  Node: Invoking find,  Next: Invoking locate,  Up: Reference
837 Invoking `find'
838 ===============
840      find [FILE...] [EXPRESSION]
842    `find' searches the directory tree rooted at each file name FILE by
843 evaluating the EXPRESSION on each file it finds in the tree.
845    `find' considers the first argument that begins with `-', `(', `)',
846 `,', or `!' to be the beginning of the expression; any arguments before
847 it are paths to search, and any arguments after it are the rest of the
848 expression.  If no paths are given, the current directory is used.  If
849 no expression is given, the expression `-print' is used.
851    `find' exits with status 0 if all files are processed successfully,
852 greater than 0 if errors occur.
854    *Note Primary Index::, for a summary of all of the tests, actions,
855 and options that the expression can contain.
857    `find' also recognizes two options for administrative use:
859 `--help'
860      Print a summary of the command-line argument format and exit.
862 `--version'
863      Print the version number of `find' and exit.
865 \x1f
866 File: find.info,  Node: Invoking locate,  Next: Invoking updatedb,  Prev: Invoking find,  Up: Reference
868 Invoking `locate'
869 =================
871      locate [OPTION...] PATTERN...
873 `--database=PATH'
874 `-d PATH'
875      Instead of searching the default file name database, search the
876      file name databases in PATH, which is a colon-separated list of
877      database file names.  You can also use the environment variable
878      `LOCATE_PATH' to set the list of database files to search.  The
879      option overrides the environment variable if both are used.
881 `--existing'
882 `-e'
883      Only print out such names that currently exist (instead of such
884      names that existed when the database was created).  Note that this
885      may slow down the program a lot, if there are many matches in the
886      database.
888 `--help'
889      Print a summary of the options to `locate' and exit.
891 `--version'
892      Print the version number of `locate' and exit.
894 \x1f
895 File: find.info,  Node: Invoking updatedb,  Next: Invoking xargs,  Prev: Invoking locate,  Up: Reference
897 Invoking `updatedb'
898 ===================
900      updatedb [OPTION...]
902 `--localpaths='PATH...''
903      Non-network directories to put in the database.  Default is `/'.
905 `--netpaths='PATH...''
906      Network (NFS, AFS, RFS, etc.) directories to put in the database.
907      The environment variable `NETPATHS' also sets this value.  Default
908      is none.
910 `--prunepaths='PATH...''
911      Directories to not put in the database, which would otherwise be.
912      The environment variable `PRUNEPATHS' also sets this value.
913      Default is `/tmp /usr/tmp /var/tmp /afs'.
915 `--prunefs='PATH...''
916      File systems to not put in the database, which would otherwise be.
917      Note that files are pruned when a file system is reached; Any file
918      system mounted under an undesired file system will be ignored.
919      The environment variable `PRUNEFS' also sets this value.  Default
920      is `nfs NFS proc'.
922 `--output=DBFILE'
923      The database file to build.  Default is system-dependent, but
924      typically `/usr/local/var/locatedb'.
926 `--localuser=USER'
927      The user to search the non-network directories as, using `su'.
928      Default is to search the non-network directories as the current
929      user.  You can also use the environment variable `LOCALUSER' to
930      set this user.
932 `--netuser=USER'
933      The user to search network directories as, using `su'(1).  Default
934      is `daemon'.  You can also use the environment variable `NETUSER'
935      to set this user.
937 \x1f
938 File: find.info,  Node: Invoking xargs,  Prev: Invoking updatedb,  Up: Reference
940 Invoking `xargs'
941 ================
943      xargs [OPTION...] [COMMAND [INITIAL-ARGUMENTS]]
945    `xargs' exits with the following status:
948      if it succeeds
951      if any invocation of the command exited with status 1-125
954      if the command exited with status 255
957      if the command is killed by a signal
960      if the command cannot be run
963      if the command is not found
966      if some other error occurred.
968 `--null'
969 `-0'
970      Input filenames are terminated by a null character instead of by
971      whitespace, and the quotes and backslash are not special (every
972      character is taken literally).  Disables the end of file string,
973      which is treated like any other argument.
975 `--eof[=EOF-STR]'
976 `-e[EOF-STR]'
977      Set the end of file string to EOF-STR.  If the end of file string
978      occurs as a line of input, the rest of the input is ignored.  If
979      EOF-STR is omitted, there is no end of file string.  If this
980      option is not given, the end of file string defaults to `_'.
982 `--help'
983      Print a summary of the options to `xargs' and exit.
985 `--replace[=REPLACE-STR]'
986 `-i[REPLACE-STR]'
987      Replace occurences of REPLACE-STR in the initial arguments with
988      names read from standard input.  Also, unquoted blanks do not
989      terminate arguments.  If REPLACE-STR is omitted, it defaults to
990      `{}' (like for `find -exec').  Implies `-x' and `-l 1'.
992 `--max-lines[=MAX-LINES]'
993 `-l[MAX-LINES]'
994      Use at most MAX-LINES nonblank input lines per command line;
995      MAX-LINES defaults to 1 if omitted.  Trailing blanks cause an
996      input line to be logically continued on the next input line, for
997      the purpose of counting the lines.  Implies `-x'.
999 `--max-args=MAX-ARGS'
1000 `-n MAX-ARGS'
1001      Use at most MAX-ARGS arguments per command line.  Fewer than
1002      MAX-ARGS arguments will be used if the size (see the `-s' option)
1003      is exceeded, unless the `-x' option is given, in which case
1004      `xargs' will exit.
1006 `--interactive'
1007 `-p'
1008      Prompt the user about whether to run each command line and read a
1009      line from the terminal.  Only run the command line if the response
1010      starts with `y' or `Y'.  Implies `-t'.
1012 `--no-run-if-empty'
1013 `-r'
1014      If the standard input does not contain any nonblanks, do not run
1015      the command.  By default, the command is run once even if there is
1016      no input.
1018 `--max-chars=MAX-CHARS'
1019 `-s MAX-CHARS'
1020      Use at most MAX-CHARS characters per command line, including the
1021      command and initial arguments and the terminating nulls at the
1022      ends of the argument strings.
1024 `--verbose'
1025 `-t'
1026      Print the command line on the standard error output before
1027      executing it.
1029 `--version'
1030      Print the version number of `xargs' and exit.
1032 `--exit'
1033 `-x'
1034      Exit if the size (see the -S option) is exceeded.
1036 `--max-procs=MAX-PROCS'
1037 `-P MAX-PROCS'
1038      Run up to MAX-PROCS processes at a time; the default is 1.  If
1039      MAX-PROCS is 0, `xargs' will run as many processes as possible at
1040      a time.
1042 \x1f
1043 File: find.info,  Node: Primary Index,  Prev: Reference,  Up: Top
1045 `find' Primary Index
1046 ********************
1048    This is a list of all of the primaries (tests, actions, and options)
1049 that make up `find' expressions for selecting files.  *Note find
1050 Expressions::, for more information on expressions.
1052 * Menu:
1054 * -amin:                                 Age Ranges.
1055 * -anewer:                               Comparing Timestamps.
1056 * -atime:                                Age Ranges.
1057 * -cmin:                                 Age Ranges.
1058 * -cnewer:                               Comparing Timestamps.
1059 * -ctime:                                Age Ranges.
1060 * -daystart:                             Age Ranges.
1061 * -depth:                                Directories.
1062 * -empty:                                Size.
1063 * -exec:                                 Single File.
1064 * -false:                                Combining Primaries With Operators.
1065 * -fls:                                  Print File Information.
1066 * -follow:                               Symbolic Links.
1067 * -fprint:                               Print File Name.
1068 * -fprint0:                              Safe File Name Handling.
1069 * -fprintf:                              Print File Information.
1070 * -fstype:                               Filesystems.
1071 * -gid:                                  Owner.
1072 * -group:                                Owner.
1073 * -ilname:                               Symbolic Links.
1074 * -iname:                                Base Name Patterns.
1075 * -inum:                                 Hard Links.
1076 * -ipath:                                Full Name Patterns.
1077 * -iregex:                               Full Name Patterns.
1078 * -links:                                Hard Links.
1079 * -lname:                                Symbolic Links.
1080 * -ls:                                   Print File Information.
1081 * -maxdepth:                             Directories.
1082 * -mindepth:                             Directories.
1083 * -mmin:                                 Age Ranges.
1084 * -mount:                                Filesystems.
1085 * -mtime:                                Age Ranges.
1086 * -name:                                 Base Name Patterns.
1087 * -newer:                                Comparing Timestamps.
1088 * -nogroup:                              Owner.
1089 * -noleaf:                               Directories.
1090 * -nouser:                               Owner.
1091 * -ok:                                   Querying.
1092 * -path:                                 Full Name Patterns.
1093 * -perm:                                 Permissions.
1094 * -print:                                Print File Name.
1095 * -print0:                               Safe File Name Handling.
1096 * -printf:                               Print File Information.
1097 * -prune:                                Directories.
1098 * -regex:                                Full Name Patterns.
1099 * -size:                                 Size.
1100 * -true:                                 Combining Primaries With Operators.
1101 * -type:                                 Type.
1102 * -uid:                                  Owner.
1103 * -used:                                 Comparing Timestamps.
1104 * -user:                                 Owner.
1105 * -xdev:                                 Filesystems.
1106 * -xtype:                                Type.