find: Fast Full Name Search

1 
1 2.1.3 Fast Full Name Search
1 ---------------------------
1 
1 To search for files by name without having to actually scan the
1 directories on the disk (which can be slow), you can use the 'locate'
1 program.  For each shell pattern you give it, 'locate' searches one or
1 more databases of file names and displays the file names that contain
1 the pattern.  ⇒Shell Pattern Matching, for details about shell
1 patterns.
1 
1    If a pattern is a plain string - it contains no metacharacters -
1 'locate' displays all file names in the database that contain that
1 string.  If a pattern contains metacharacters, 'locate' only displays
1 file names that match the pattern exactly.  As a result, patterns that
1 contain metacharacters should usually begin with a '*', and will most
1 often end with one as well.  The exceptions are patterns that are
1 intended to explicitly match the beginning or end of a file name.
1 
1    If you only want 'locate' to match against the last component of the
1 file names (the "base name" of the files) you can use the '--basename'
1 option.  The opposite behaviour is the default, but can be selected
1 explicitly by using the option '--wholename'.
1 
1    The command
1      locate PATTERN
1 
1    is almost equivalent to
1      find DIRECTORIES -name PATTERN
1 
1    where DIRECTORIES are the directories for which the file name
1 databases contain information.  The differences are that the 'locate'
1 information might be out of date, and that 'locate' handles wildcards in
11 the pattern slightly differently than 'find' (⇒Shell Pattern
 Matching).
1 
1    The file name databases contain lists of files that were on the
1 system when the databases were last updated.  The system administrator
1 can choose the file name of the default database, the frequency with
1 which the databases are updated, and the directories for which they
1 contain entries.
1 
1    Here is how to select which file name databases 'locate' searches.
1 The default is system-dependent.
1 
1 '--database=PATH'
1 '-d PATH'
1      Instead of searching the default file name database, search the
1      file name databases in PATH, which is a colon-separated list of
1      database file names.  You can also use the environment variable
1      'LOCATE_PATH' to set the list of database files to search.  The
1      option overrides the environment variable if both are used.
1 
1    GNU 'locate' can read file name databases generated by the 'slocate'
1 package.  However, these generally contain a list of all the files on
1 the system, and so when using this database, 'locate' will produce
11 output only for files which are accessible to you.  ⇒Invoking
 locate, for a description of the '--existing' option which is used to
1 do this.
1 
1    The 'updatedb' program can also generate database in a format
1 compatible with 'slocate'.  ⇒Invoking updatedb, for a description
1 of its '--dbformat' and '--output' options.
1