cvsimport
[findutils.git] / locate / locate.1
blobd774e117abfbf1b50fcda5cc1137738cf920b79d
1 .TH LOCATE 1 \" -*- nroff -*-
2 .SH NAME
3 locate \- list files in databases that match a pattern
4 .SH SYNOPSIS
5 .B locate
6 [\-d path | \-\-database=path] [\-e | \-E | \-\-[non\-]existing] [\-i
7 | \-\-ignore-case] [\-0 | \-\-null] [\-c | \-\-count] [\-w | \-\-wholename]
8 |\-b | \-\-basename] [\-l N | \-\-limit=N] [\-S | \-\-statistics] [\-r
9 | \-\-regex ] [\-\-max-database-age D] [\-P | \-H | \-\-nofollow] [\-L
10 | \-\-follow] [\-\-version] [\-A | \-\-all] [\-p | \-\-print] [\-\-help] pattern...
11 .SH DESCRIPTION
12 This manual page
13 documents the GNU version of
14 .BR locate .
15 For each given pattern,
16 .B locate
17 searches one or more databases of file names and displays the
18 file names that contain the pattern.  Patterns can contain shell-style
19 metacharacters: `*', `?', and `[]'.  The metacharacters do not treat
20 `/' or `.'  specially.  Therefore, a pattern `foo*bar' can match a
21 file name that contains `foo3/bar', and a pattern `*duck*' can match a
22 file name that contains `lake/.ducky'.  Patterns that contain
23 metacharacters should be quoted to protect them from expansion by the
24 shell.
26 If a pattern is a plain string \(em it contains no metacharacters \(em
27 .B locate
28 displays all file names in the database that contain that string
29 anywhere.  If a pattern does contain metacharacters,
30 .B locate
31 only displays file names that match the pattern exactly.  As a result,
32 patterns that contain metacharacters should usually begin with a `*',
33 and will most often end with one as well.  The exceptions are patterns
34 that are intended to explicitly match the beginning or end of a file
35 name.
37 The file name databases contain lists of files that were on the system
38 when the databases were last updated.  The system administrator can
39 choose the file name of the default database, the frequency with which
40 the databases are updated, and the directories for which they contain
41 entries; see \fBupdatedb\fP(1).
43 If 
44 .BR locate 's 
45 output is going to a terminal, unusual characters in the output are 
46 escaped in the same way as for the \-print action of the 
47 .B find
48 command.  If the output is not going to a terminal, file names are
49 printed exactly as-is.
51 .SH OPTIONS
52 .TP
53 .I "\-0, \-\-null"
54 Use ASCII NUL as a separator, instead of newline.   
55 .TP
56 .I "\-A, \-\-all"
57 Print only names which match all non-option arguments, not those matching
58 one or more non-option arguments.
59 .TP
60 .I "\-b, \-\-basename"
61 Results are considered to match if the pattern specified matches the
62 final component of the name of a file as listed in the database.
63 This final component is usually referred to as the `base name'.
64 .TP
65 .I "\-c, \-\-count"
66 Instead of printing the matched filenames, just print the total 
67 number of matches we found, unless \-\-\fIprint\fP (\-p) is also present.
68 .TP
69 .I "\-d \fIpath\fP, \-\-database=\fIpath\fP"
70 Instead of searching the default file name database, search the file
71 name databases in \fIpath\fP, which is a colon-separated list of
72 database file names.  You can also use the environment variable
73 .B LOCATE_PATH
74 to set the list of database files to search.
75 The option overrides the environment variable if both are used.  Empty
76 elements in the path are taken to be synonyms for the file name of the
77 default database.
78 A database can be supplied on stdin, using `\-' as an element
79 of \fIpath\fP. If more than one element of \fIpath\fP is `\-',
80 later instances are ignored (and a warning message is printed).
81 .IP
82 The file name database format changed starting with GNU
83 .B find
84 and
85 .B locate
86 version 4.0 to allow machines with different byte orderings to share
87 the databases.  This version of
88 .B locate
89 can automatically recognize and read databases produced for older
90 versions of GNU
91 .B locate
92 or Unix versions of
93 .B locate
95 .BR find .
96 Support for the old locate database format will be discontinued in a
97 future release.
98 .TP
99 .I "\-e, \-\-existing"
100 Only print out such names that currently exist (instead of such names
101 that existed when the database was created).
102 Note that this may slow down the program a lot, if there are many matches
103 in the database.  If you are using this option within a program,
104 please note that it is possible for the file to be deleted after 
105 .B locate 
106 has checked that it exists, but before you use it.
108 .I "\-E, \-\-non\-existing"
109 Only print out such names that currently do not exist (instead of such names
110 that existed when the database was created).
111 Note that this may slow down the program a lot, if there are many matches
112 in the database.
114 .I "\-\-help"
115 Print a summary of the options to
116 .B locate
117 and exit.
119 .I "\-i, \-\-ignore-case"
120 Ignore case distinctions in both the pattern and the file names.
122 .I "\-l N, \-\-limit=N"
123 Limit the number of matches to N.  If a limit is set via this option,
124 the number of results printed for the \-c option will never be larger
125 than this number.
127 .I "\-L, \-\-follow"
128 If testing for the existence of files (with the \-e or \-E options),
129 consider broken symbolic links to be non-existing.   This is the default.
131 .I "\-\-max-database-age D"
132 Normally, 
133 .B locate
134 will issue a warning message when it searches a database which is more
135 than 8 days old.  This option changes that value to something other
136 than 8.  The effect of specifying a negative value is undefined.
138 .I "\-m, \-\-mmap"
139 Accepted but does nothing, for compatibility with BSD 
140 .BR locate .
142 .I "\-P, \-H, \-\-nofollow"
143 If testing for the existence of files (with the \-e or \-E options), treat
144 broken symbolic links as if they were existing files.  The \-H
145 form of this option is provided purely for similarity with
146 .BR find ;
147 the use of \-P is recommended over \-H.
149 .I "\-p, \-\-print"
150 Print search results when they normally would not, because of the presence
151 of \-\-statistics (\-S) or \-\-count (\-c).
153 .I "\-r, \-\-regex "
154 The pattern specified on the command line is understood to be a
155 regular expression, as opposed to a glob pattern.  The Regular
156 expressions work in the same was as in 
157 .B emacs
158 and 
159 .BR find ,
160 except for the fact that "." will match a newline.
161 Filenames whose full paths match the specified regular expression are
162 printed (or, in the case of the \-c option, counted).  If you wish to
163 anchor your regular expression at the ends of the full path name, then
164 as is usual with regular expressions, you should use the characters ^
165 and $ to signify this.  
167 .I "\-s, \-\-stdio"
168 Accepted but does nothing, for compatibility with BSD 
169 .BR locate .
171 .I "\-S, \-\-statistics"
172 Print various statistics about each locate database and then exit
173 without performing a search, unless non-option arguments are given.
174 For compatibility with BSD, \-S is accepted as a synonym
175 for \-\-statistics.  However, the ouptut of 
176 .B locate \-S 
177 is different for the GNU and BSD implementations of 
178 .BR locate .
180 .I "\-\-version"
181 Print the version number of
182 .B locate
183 and exit.
185 .I "\-w, \-\-wholename"
186 Match against the whole name of the file as listed in the database.
187 This is the default.
188 .SH ENVIRONMENT
190 .B LOCATE_PATH
191 Colon-separated list of databases to search.  If the value has a
192 leading or trailing colon, or has two colons in a row, you may get
193 results that vary between different versions of 
194 .BR locate .
196 .SH "SEE ALSO"
197 \fBfind\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1), \fBxargs\fP(1),
198 \fBglob\fP(3),
199 \fBFinding Files\fP (on-line in Info, or printed)
200 .SH "HISTORY"
201 The 
202 .B locate
203 program started life as the BSD fast find program, contributed to BSD
204 by James A. Woods.  This was described by his paper 
205 .I Finding Files Fast
206 which was published in Usenix 
207 .IR ;login: , 
208 Vol 8, No 1, February/March, 1983, pp. 8-10.   When the 
209 .B find 
210 program began to assume a default
211 .B -print 
212 action if no action was specified, this changed the interpretation of
213 .B find 
214 .BR pattern .
215 The BSD developers therefore moved the fast find functionality into 
216 .BR locate .
217 The GNU implementation of 
218 .B locate
219 appears to be derived from the same code.
221 Significant changes to 
222 .B locate
223 in reverse order:
225 tab(|);
227 4.3.7 | Byte-order independent support for old database format
228 4.3.3 | locate \fI\-i\fR supports multi-byte characters correctly
229       | Introduced \fI\-\-max_db_age\fR 
230 4.3.2 | Support for the slocate database format
231 4.2.22| Introduced the \fI\-\-all\fR option
232 4.2.15| Introduced the \fI\-\-regex\fR option
233 4.2.14| Introduced options \fI\-L, \-P, \-H\fR
234 4.2.12| Empty items in \fBLOCATE_PATH\fR now indicate the default database
235 4.2.11| Introduced the \fI\-\-statistics\fR option
236 4.2.4 | Introduced \fI\-\-count\fR and \fI\-\-limit\fR
237 4.2.0 | Glob characters cause matching against the whole file name
238 4.0   | Introduced the LOCATE02 database format
239 3.7   | Locate can search multiple databases
241 .SH "BUGS"
243 The locate database correctly handles filenames containing newlines,
244 but only if the system's sort command has a working
246 option.  If you suspect that 
247 .B locate
248 may need to return filenames containing newlines, consider using its
249 .I \-\-null 
250 option.
252 The best way to report a bug is to use the form at
253 http://savannah.gnu.org/bugs/?group=findutils.  
254 The reason for this is that you will then be able to track progress in
255 fixing the problem.   Other comments about \fBlocate\fP(1) and about
256 the findutils package in general can be sent to the 
257 .I bug-findutils
258 mailing list.  To join the list, send email to 
259 .IR bug-findutils-request@gnu.org .