Blob Blame History Raw
.\" A man page for locate(1). -*- nroff -*-
.\"
.\" Copyright (C) 2012 Red Hat, Inc. All rights reserved.
.\"
.\" This copyrighted material is made available to anyone wishing to use,
.\" modify, copy, or redistribute it subject to the terms and conditions of the
.\" GNU General Public License v.2.
.\"
.\" This program is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
.\" more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
.\"
.\" Author: Miloslav Trmac <mitr@redhat.com>
.TH locate 1 "Sep 2012" mlocate

.SH NAME
locate \- find files by name

.SH SYNOPSIS

\fBlocate\fR [\fIOPTION\fR]... \fIPATTERN\fR...

.SH DESCRIPTION
.B locate
reads one or more databases prepared by
.BR updatedb (8)
and writes file names matching at least one of the \fIPATTERN\fRs to standard
output, one per line.

If
.B \-\-regex
is not specified,
\fIPATTERN\fRs can contain globbing characters.
If any
.I PATTERN
contains no globbing characters,
.B locate
behaves as if the pattern were \fB*\fIPATTERN\fB*\fR.

By default,
.B locate
does not check whether files found in database still exist
(but it does require all parent directories to exist
if the database was built with \fB\-\-require\-visibility no\fR).
.B locate
can never report files created after the most recent update of the relevant
database.

.SH EXIT STATUS
.B locate
exits with status 0 if any match was found or if
.B locate
was invoked with one of the \fB\-\-limit 0\fR, \fB\-\-help\fR,
.B \-\-statistics
or
.B \-\-version
options.
If no match was found or a fatal error was encountered,
.B locate
exits with status 1.

Errors encountered while reading a database are not fatal,
search continues in other specified databases, if any.

.SH OPTIONS
.TP
\fB\-A\fR, \fB\-\-all\fR
Print only entries that match all \fIPATTERN\fRs
instead of requiring only one of them to match.

.TP
\fB\-b\fR, \fB\-\-basename\fR
Match only the base name against the specified patterns.
This is the opposite of \fB\-\-wholename\fR.

.TP
\fB\-c\fR, \fB\-\-count\fR
Instead of writing file names on standard output,
write the number of matching entries only.

.TP
\fB\-d, \fB\-\-database\fR \fIDBPATH\fR
Replace the default database with \fIDBPATH\fR.
.I DBPATH
is a \fB:\fR-separated list of database file names.
If more than one
.B \-\-database
option is specified,
the resulting path is a concatenation of the separate paths.

An empty database file name is replaced by the default database.
A database file name
.B \-
refers to the standard input.
Note that a database can be read from the standard input only once.

.TP
\fB\-e\fR, \fB\-\-existing\fR
Print only entries that refer to files existing at the time
.B locate
is run.

.TP
\fB\-L\fR, \fB\-\-follow\fR
When checking whether files exist (if the
.B \-\-existing
option is specified),
follow trailing symbolic links.
This causes broken symbolic links to be omitted from the output.

This is the default behavior.
The opposite can be specified using \fB\-\-nofollow\fR.

.TP
\fB\-h\fR, \fB\-\-help\fR
Write a summary of the available options to standard output
and exit successfully.

.TP
\fB\-i\fR, \fB\-\-ignore\-case\fR
Ignore case distinctions when matching patterns.

.TP
\fB\-l\fR, \fB\-\-limit\fR, \fB\-n\fR \fILIMIT\fR
Exit successfully after finding
.I LIMIT
entries.
If the
.B \-\-count
option is specified,
the resulting count is also limited to \fILIMIT\fR.

.TP
\fB\-m\fR, \fB\-\-mmap\fR
Ignored, for compatibility with
.SM BSD
and
.SM GNU
\fBlocate\fR.

.TP
\fB\-P\fR, \fB\-\-nofollow\fR, \fB\-H\fR
When checking whether files exist (if the
.B \-\-existing
option is specified),
do not follow trailing symbolic links.
This causes broken symbolic links to be reported like other files.

This is the opposite of \fB\-\-follow\fR.

.TP
\fB\-0\fR, \fB\-\-null\fR
Separate the entries on output using the
.SM ASCII NUL
character instead of
writing each entry on a separate line.
This option is designed for interoperability with the
.B \-\-null
option of
.SM GNU
.BR xargs (1).

.TP
\fB\-S\fR, \fB\-\-statistics\fR
Write statistics about each read database to standard output instead of
searching for files
and exit successfully.

.TP
\fB\-q\fR, \fB\-\-quiet\fR
Write no messages about errors encountered while reading and processing
databases.

.TP
\fB\-r\fR, \fB\-\-regexp\fR \fIREGEXP\fR
Search for a basic regexp \fIREGEXP\fR.
No \fIPATTERN\fRs are allowed if this option is used,
but this option can be specified multiple times.

.TP
\fB\-\-regex\fR
Interpret all \fIPATTERN\fRs as extended regexps.

.TP
\fB\-s\fR, \fB\-\-stdio\fR
Ignored, for compatibility with
.SM BSD
and
.SM GNU
\fBlocate\fR.

.TP
\fB\-V\fR, \fB\-\-version\fR
Write information about the version and license of
.B locate
on standard output and exit successfully.

.TP
\fB\-w\fR, \fB\-\-wholename\fR
Match only the whole path name against the specified patterns.

This is the default behavior.
The opposite can be specified using \fB\-\-basename\fR.

.SH EXAMPLES
To search for a file named exactly
.I NAME
(not \fB*\fINAME\fB*\fR), use
.RS
.B locate -b
\fB'\\\fINAME\fB'\fR
.RE
Because \fB\\\fR is a globbing character,
this disables the implicit replacement of
.I NAME
by \fB*\fINAME\fB*\fR.

.SH FILES
.TP
\fB@dbfile@\fR
The database searched by default.

.SH ENVIRONMENT
.TP
\fBLOCATE_PATH\fR
Path to additional databases,
added after the default database or the databases specified using the
.B \-\-database
option.

.SH NOTES
The order in which the requested databases are processed is unspecified,
which allows
.B locate
to reorder the database path for security reasons.

.B locate
attempts to be compatible to
.B slocate
(without the options used for creating databases) and
.SM GNU
\fBlocate\fR, in that order.
This is the reason for the impractical default \fB\-\-follow\fR option
and for the confusing set of \fB\-\-regex\fR and \fB\-\-regexp\fR options.

The short spelling of the \fB\-r\fR option is incompatible to
.SM GNU
\fBlocate\fR,
where it corresponds to the \fB\-\-regex\fR option.
Use the long option names to avoid confusion.

The
.B LOCATE_PATH
environment variable replaces the default database in
.SM BSD
and
.SM GNU
\fBlocate\fR,
but it is added to other databases in this implementation and \fBslocate\fR.

.SH AUTHOR
Miloslav Trmac <mitr@redhat.com>

.SH SEE ALSO
.BR updatedb (8)