summaryrefslogtreecommitdiff
path: root/locate/locate.1
blob: 82c4c08f239c9d3e9d4401d49bc7bde8c6e7f168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
.TH LOCATE 1 \" -*- nroff -*-
.SH NAME
locate \- list files in databases that match a pattern
.SH SYNOPSIS
.B locate
[\-d path | \-\-database=path] [\-e | \-\-existing] [\-i | \-\-ignore-case]
[\-0 | \-\-null] [\-c | \-\-count] [\-w | \-\-wholename] [\-b | \-\-basename] 
[\-l N | \-\-limit=N] [\-S | \-\-statistics] [\-\-version] 
[\-P | \-H | \-\-nofollow] [\-L | \-\-follow] [\-\-help] pattern...
.SH DESCRIPTION
This manual page
documents the GNU version of
.BR locate .
For each given pattern,
.B locate
searches one or more databases of file names and displays the
file names that contain the pattern.  Patterns can contain shell-style
metacharacters: `*', `?', and `[]'.  The metacharacters do not treat
`/' or `.'  specially.  Therefore, a pattern `foo*bar' can match a
file name that contains `foo3/bar', and a pattern `*duck*' can match a
file name that contains `lake/.ducky'.  Patterns that contain
metacharacters should be quoted to protect them from expansion by the
shell.
.P
If a pattern is a plain string \(em it contains no metacharacters \(em
.B locate
displays all file names in the database that contain that string
anywhere.  If a pattern does contain metacharacters,
.B locate
only displays file names that match the pattern exactly.  As a result,
patterns that contain metacharacters should usually begin with a `*',
and will most often end with one as well.  The exceptions are patterns
that are intended to explicitly match the beginning or end of a file
name.
.P
The file name databases contain lists of files that were on the system
when the databases were last updated.  The system administrator can
choose the file name of the default database, the frequency with which
the databases are updated, and the directories for which they contain
entries; see \fBupdatedb\fP(1).
.SH OPTIONS
.TP
.I "\-c, \-\-count"
Instead of printing the matched filenames, just print the total 
number of matches we found.
.TP
.I "\-d \fIpath\fP, \-\-database=\fIpath\fP"
Instead of searching the default file name database, search the file
name databases in \fIpath\fP, which is a colon-separated list of
database file names.  You can also use the environment variable
.B LOCATE_PATH
to set the list of database files to search.
The option overrides the environment variable if both are used.  Empty
elements in the path are taken to be synonyms for the file name of the
default database.
.IP
The file name database format changed starting with GNU
.B find
and
.B locate
version 4.0 to allow machines with diffent byte orderings to share
the databases.  This version of
.B locate
can automatically recognize and read databases produced for older
versions of GNU
.B locate
or Unix versions of
.B locate
or
.BR find .
Support for the old locate database format will be discontinued in a
future release.
.TP
.I "\-e, \-\-existing"
Only print out such names that currently exist (instead of such names
that existed when the database was created).
Note that this may slow down the program a lot, if there are many matches
in the database.  If you are using this option within a program,
please note that it is possible for the file to be deleted after 
.B locate 
has checked that it exists, but before you use it.
.TP
.I "\-L, \-\-follow"
If testing for the existence of files (with the \-e option), omit
broken symbolic links.   This is the default.
.TP
.I "\-P, \-H, \-\-nofollow"
If testing for the existence of files (with the \-e option), treat
broken symbolic links count as if they were exiting files.  The \-H
form of this option is provided purely for similarity with
.BR find ;
the use of \-P is recommended over \-H.
.TP
.I "\-i, \-\-ignore-case"
Ignore case distinctions in both the pattern and the file names.
.TP
.I "\-l N, \-\-limit=N"
Limit the number of matches to N.  If a limit is set via this option,
the number of results printed for the \-c option will never be larger
than this number.
.TP
.I "\-0, \-\-null"
Use ASCII NUL as a separator, instead of newline.   
.TP
.I "\-w, \-\-wholename"
Match against the whole name of the file as listed in the database.
This is the default.
.TP
.I "\-b, \-\-basename"
Results are considered to match if the pattern specified matches the
final component of the name of a file as listed in the database.
This final component is usually referred to as the `base name'.
.TP
.I "\-\-statistics"
Print various statistics about each locate database and then exit
without performing a search.  Any patterns given on the command line
are ignored.  For compatibility with BSD, \-S is accepted as a synonym
for \-\-statistics.
.TP
.I "\-\-help"
Print a summary of the options to
.B locate
and exit.
.TP
.I "\-\-version"
Print the version number of
.B locate
and exit.
.SH ENVIRONMENT
.TP
.B LOCATE_PATH
Colon-separated list of databases to search.  If the value has a
leading or trailing colon, or has two colons in a row, you may get
results that vary between different versions of 
.BR locate .

.SH "SEE ALSO"
\fBfind\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1), \fBxargs\fP(1)
\fBFinding Files\fP (on-line in Info, or printed)
.SH "BUGS"
.P
The locate database correctly handles filenames containing newlines,
but only if the system's sort command has a working
.I \-z
option.  If you suspect that 
.B locate
may need to return filenames containing newlines, consider using its
.I \-\-null 
option.
.P
The best way to report a bug is to use the form at
http://savannah.gnu.org/bugs/?group=findutils.  
The reason for this is that you will then be able to track progress in
fixing the problem.   Other comments about \fBlocate\fP(1) and about
the findutils package in general can be sent to the 
.I bug-findutils
mailing list.  To join the list, send email to 
.IR bug-findutils-request@gnu.org .