*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> locate (1)              



NAME    [Toc]    [Back]

     locate - find filenames quickly

SYNOPSIS    [Toc]    [Back]

     locate [-cimSs] [-d database] [-l limit] pattern [...]

DESCRIPTION    [Toc]    [Back]

     The locate utility searches a  database  for  all  pathnames
which match the
     specified  pattern.  The database is recomputed periodically
     weekly or daily), and contains the pathnames  of  all  files
which are publicly

     Shell  globbing  and  quoting characters (`*', `?', `', `[',
and `]') may
     be used in pattern, although they will have  to  be  escaped
from the shell.
     Preceding any character with a backslash (`') eliminates any
     meaning which it may have.  The matching differs in that  no
     must be matched explicitly, including slashes (`/').

     As  a special case, a pattern containing no globbing characters (``foo'')
     is matched as though it were ``*foo*''.

     Historically, locate stores only characters between  32  and
127.  The current
  implementation  stores  all  characters except newline
(`0) and NUL
     (` ').  The 8-bit character support  does  not  waste  extra
space for plain
     ASCII  file  names.  Characters less than 32 or greater than
127 are stored
     as 2 bytes.

     The options are as follows:

     -c      Suppress normal output; instead  print  a  count  of
matching file

     -d database
             Search  in database instead of the default file name
             Multiple -d options are allowed.  Each additional -d
option adds
             the  specified  database to the list of databases to
be searched.

             database may be a colon-separated list of databases.
A single
             colon is a reference to the default database.

                   $ locate -d $HOME/lib/mydb: foo

             will   first   search  for  the  string  ``foo''  in
$HOME/lib/mydb and
             then in /var/db/locate.database.

                   $   locate    -d    $HOME/lib/mydb::/cdrom/locate.database foo

             will   first   search  for  the  string  ``foo''  in
$HOME/lib/mydb and
             then in /var/db/locate.database and then in

                   $ locate -d db1 -d db2 -d db3 pattern

             is the same as

                   $ locate -d db1:db2:db3 pattern


                   $ locate -d db1:db2 -d db3 pattern

             If `-' is given as the database name, standard input
will be read
             instead.    For   example,  you  can  compress  your
database and use:

                   $ zcat database.gz | locate -d - pattern

             This might be useful on machines with  a  fast  CPU,
little RAM and
             slow  I/O.   Note:  You can only use one pattern for

     -i      Ignore case distinctions in both the pattern and the

     -l number
             Limit output to number of file names and exit.

     -m       Use  mmap(2) instead of the stdio(3) library.  This
is the default
             behavior.  Usually faster in most cases.

     -S      Print some statistics about the database and exit.

     -s      Use the stdio(3) library instead of mmap(2).

ENVIRONMENT    [Toc]    [Back]

     LOCATE_PATH  Path to the locate database if set and not empty; ignored if
                  the -d option was specified.

FILES    [Toc]    [Back]

     /etc/weekly                     script   that   starts   the
database rebuild
     /usr/libexec/locate.updatedb  script to  update  the  locate
     /var/db/locate.database       locate database

SEE ALSO    [Toc]    [Back]

     find(1), fnmatch(3), locate.updatedb(8), weekly(8)

     Woods,  James  A.,  "Finding  Files  Fast", ;login, 8:1, pp.
8-10, 1983.

HISTORY    [Toc]    [Back]

     The locate command appeared in 4.4BSD.

BUGS    [Toc]    [Back]

     locate may fail to list some files that are present, or  may
list files
     that  have  been  removed  from the system.  This is because
locate only reports
 files that are present in a periodically reconstructed
     (typically  rebuilt  once  a  week by the weekly(8) script).
Use find(1) to
     locate files that are of a more transitory nature.

     The locate  database  is  built  by  user  ``nobody''  using
find(1).  This will
     skip  directories which are not readable by user ``nobody'',
     ``nobody'', or the world.  E.g., if your home  directory  is
not worldreadable,
 your files will not appear in the database.

     The  locate  database  is not byte order independent.  It is
not possible to
     share the databases between machines with different byte order.  The current
  locate  implementation  understands  databases in host
byte order or
     network byte order.  So a little-endian machine can't understand a locate
     database which was built on a big-endian machine.

OpenBSD      3.6                           June      6,      1993
[ Back ]
 Similar pages
Name OS Title
FLtoPopDB IRIX Converts filenames to serialized DNA.
basename Linux strip directory and suffix from filenames
lessecho Linux expand metacharacters, such as * and ?, in filenames on Unix systems.
ffs Tru64 Find first set bit
ffs OpenBSD find first bit set in a bit string
find IRIX find files
ffs FreeBSD find first bit set in a bit string
find HP-UX find files
strstr Tru64 Find a substring
ttyname IRIX find name of a terminal
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service