Merged latest changes from 4.2.x branch
[findutils.git] / locate / locate.1
blobc9023e2fc54f2b75aea5d44051b399b8c7222e7b
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 ] [\-P | \-H | \-\-nofollow] [\-L | \-\-follow] [\-\-version]
10 [\-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 "\-A, \-\-all"
54 Print only names which match all non-option arguments, not those matching
55 one or more non-option arguments.
56 .TP
57 .I "\-c, \-\-count"
58 Instead of printing the matched filenames, just print the total 
59 number of matches we found, unless \-\-\fIprint\fP (\-p) is also present.
60 .TP
61 .I "\-d \fIpath\fP, \-\-database=\fIpath\fP"
62 Instead of searching the default file name database, search the file
63 name databases in \fIpath\fP, which is a colon-separated list of
64 database file names.  You can also use the environment variable
65 .B LOCATE_PATH
66 to set the list of database files to search.
67 The option overrides the environment variable if both are used.  Empty
68 elements in the path are taken to be synonyms for the file name of the
69 default database.
70 A database can be supplied on stdin, using `\-' as an element
71 of \fIpath\fP. If more than one element of \fIpath\fP is `\-',
72 later instances are ignored (and a warning message is printed).
73 .IP
74 The file name database format changed starting with GNU
75 .B find
76 and
77 .B locate
78 version 4.0 to allow machines with different byte orderings to share
79 the databases.  This version of
80 .B locate
81 can automatically recognize and read databases produced for older
82 versions of GNU
83 .B locate
84 or Unix versions of
85 .B locate
87 .BR find .
88 Support for the old locate database format will be discontinued in a
89 future release.
90 .TP
91 .I "\-e, \-\-existing"
92 Only print out such names that currently exist (instead of such names
93 that existed when the database was created).
94 Note that this may slow down the program a lot, if there are many matches
95 in the database.  If you are using this option within a program,
96 please note that it is possible for the file to be deleted after 
97 .B locate 
98 has checked that it exists, but before you use it.
99 .TP
100 .I "\-E, \-\-non\-existing"
101 Only print out such names that currently do not exist (instead of such names
102 that existed when the database was created).
103 Note that this may slow down the program a lot, if there are many matches
104 in the database.
106 .I "\-L, \-\-follow"
107 If testing for the existence of files (with the \-e or \-E options),
108 consider broken symbolic links to be non-existing.   This is the default.
110 .I "\-P, \-H, \-\-nofollow"
111 If testing for the existence of files (with the \-e or \-E options), treat
112 broken symbolic links as if they were existing files.  The \-H
113 form of this option is provided purely for similarity with
114 .BR find ;
115 the use of \-P is recommended over \-H.
117 .I "\-i, \-\-ignore-case"
118 Ignore case distinctions in both the pattern and the file names.
120 .I "\-l N, \-\-limit=N"
121 Limit the number of matches to N.  If a limit is set via this option,
122 the number of results printed for the \-c option will never be larger
123 than this number.
125 .I "\-m, \-\-mmap"
126 Accepted but does nothing, for compatibility with BSD 
127 .BR locate .
129 .I "\-0, \-\-null"
130 Use ASCII NUL as a separator, instead of newline.   
132 .I "\-p, \-\-print"
133 Print search results when they normally would not, because of the presence
134 of \-\-statistics (\-S) or \-\-count (\-c).
136 .I "\-w, \-\-wholename"
137 Match against the whole name of the file as listed in the database.
138 This is the default.
140 .I "\-b, \-\-basename"
141 Results are considered to match if the pattern specified matches the
142 final component of the name of a file as listed in the database.
143 This final component is usually referred to as the `base name'.
145 .I "\-r, \-\-regex "
146 The pattern specified on the command line is understood to be a
147 regular expression, as opposed to a glob pattern.  The Regular
148 expressions work in the same was as in 
149 .B emacs
150 and 
151 .BR find ,
152 except for the fact that "." will match a newline.
153 Filenames whose full paths match the specified regular expression are
154 printed (or, in the case of the \-c option, counted).  If you wish to
155 anchor your regular expression at the ends of the full path name, then
156 as is usual with regular expressions, you should use the characters ^
157 and $ to signify this.  
159 .I "\-s, \-\-stdio"
160 Accepted but does nothing, for compatibility with BSD 
161 .BR locate .
163 .I "\-S, \-\-statistics"
164 Print various statistics about each locate database and then exit
165 without performing a search, unless non-option arguments are given.
166 For compatibility with BSD, \-S is accepted as a synonym
167 for \-\-statistics.  However, the ouptut of 
168 .B locate \-S 
169 is different for the GNU and BSD implementations of 
170 .BR locate .
172 .I "\-\-help"
173 Print a summary of the options to
174 .B locate
175 and exit.
177 .I "\-\-version"
178 Print the version number of
179 .B locate
180 and exit.
181 .SH ENVIRONMENT
183 .B LOCATE_PATH
184 Colon-separated list of databases to search.  If the value has a
185 leading or trailing colon, or has two colons in a row, you may get
186 results that vary between different versions of 
187 .BR locate .
189 .SH "SEE ALSO"
190 \fBfind\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1), \fBxargs\fP(1),
191 \fBglob\fP(3),
192 \fBFinding Files\fP (on-line in Info, or printed)
193 .SH "BUGS"
195 The locate database correctly handles filenames containing newlines,
196 but only if the system's sort command has a working
197 .I \-z
198 option.  If you suspect that 
199 .B locate
200 may need to return filenames containing newlines, consider using its
201 .I \-\-null 
202 option.
204 The best way to report a bug is to use the form at
205 http://savannah.gnu.org/bugs/?group=findutils.  
206 The reason for this is that you will then be able to track progress in
207 fixing the problem.   Other comments about \fBlocate\fP(1) and about
208 the findutils package in general can be sent to the 
209 .I bug-findutils
210 mailing list.  To join the list, send email to 
211 .IR bug-findutils-request@gnu.org .