]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/locate/locate/locate.1
MFV r359442: bmake: import -fno-common fix build back from upstream
[FreeBSD/FreeBSD.git] / usr.bin / locate / locate / locate.1
1 .\" Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
2 .\" Copyright (c) 1990, 1993
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. Neither the name of the University nor the names of its contributors
14 .\"    may be used to endorse or promote products derived from this software
15 .\"    without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" SUCH DAMAGE.
28 .\"
29 .\"     @(#)locate.1    8.1 (Berkeley) 6/6/93
30 .\" $FreeBSD$
31 .\"
32 .Dd August 17, 2006
33 .Dt LOCATE 1
34 .Os
35 .Sh NAME
36 .Nm locate
37 .Nd find filenames quickly
38 .Sh SYNOPSIS
39 .Nm
40 .Op Fl 0Scims
41 .Op Fl l Ar limit
42 .Op Fl d Ar database
43 .Ar pattern ...
44 .Sh DESCRIPTION
45 The
46 .Nm
47 program searches a database for all pathnames which match the specified
48 .Ar pattern .
49 The database is recomputed periodically (usually weekly or daily),
50 and contains the pathnames
51 of all files which are publicly accessible.
52 .Pp
53 Shell globbing and quoting characters
54 .Dq ( * ,
55 .Dq \&? ,
56 .Dq \e ,
57 .Dq \&[
58 and
59 .Dq \&] )
60 may be used in
61 .Ar pattern ,
62 although they will have to be escaped from the shell.
63 Preceding any character with a backslash
64 .Pq Dq \e
65 eliminates any special
66 meaning which it may have.
67 The matching differs in that no characters must be matched explicitly,
68 including slashes
69 .Pq Dq / .
70 .Pp
71 As a special case, a pattern containing no globbing characters
72 .Pq Dq foo
73 is matched as though it were
74 .Dq *foo* .
75 .Pp
76 Historically, locate only stored characters between 32 and 127.
77 The
78 current implementation store any character except newline
79 .Pq Sq \en
80 and
81 .Dv NUL
82 .Pq Sq \e0 .
83 The 8-bit character support does not waste extra space for
84 plain ASCII file names.
85 Characters less than 32 or greater than 127
86 are stored in 2 bytes.
87 .Pp
88 The following options are available:
89 .Bl -tag -width 10n
90 .It Fl 0
91 Print pathnames separated by an
92 .Tn ASCII
93 .Dv NUL
94 character (character code 0) instead of default NL
95 (newline, character code 10).
96 .It Fl S
97 Print some statistics about the database and exit.
98 .It Fl c
99 Suppress normal output; instead print a count of matching file names.
100 .It Fl d Ar database
101 Search in
102 .Ar database
103 instead of the default file name database.
104 Multiple
105 .Fl d
106 options are allowed.
107 Each additional
108 .Fl d
109 option adds the specified database to the list
110 of databases to be searched.
111 .Pp
112 The option
113 .Ar database
114 may be a colon-separated list of databases.
115 A single colon is a reference
116 to the default database.
117 .Bd -literal
118 $ locate -d $HOME/lib/mydb: foo
119 .Ed
120 .Pp
121 will first search string
122 .Dq foo
123 in
124 .Pa $HOME/lib/mydb
125 and then in
126 .Pa /var/db/locate.database .
127 .Bd -literal
128 $ locate -d $HOME/lib/mydb::/cdrom/locate.database foo
129 .Ed
130 .Pp
131 will first search string
132 .Dq foo
133 in
134 .Pa $HOME/lib/mydb
135 and then in
136 .Pa /var/db/locate.database
137 and then in
138 .Pa /cdrom/locate.database .
139 .Pp
140 .Dl "$ locate -d db1 -d db2 -d db3 pattern"
141 .Pp
142 is the same as
143 .Pp
144 .Dl "$ locate -d db1:db2:db3 pattern"
145 .Pp
146 or
147 .Pp
148 .Dl "$ locate -d db1:db2 -d db3 pattern"
149 .Pp
150 If
151 .Fl
152 is given as the database name, standard input will be read instead.
153 For example, you can compress your database
154 and use:
155 .Bd -literal
156 $ zcat database.gz | locate -d - pattern
157 .Ed
158 .Pp
159 This might be useful on machines with a fast CPU and little RAM and slow
160 I/O.
161 Note: you can only use
162 .Em one
163 pattern for stdin.
164 .It Fl i
165 Ignore case distinctions in both the pattern and the database.
166 .It Fl l Ar number
167 Limit output to
168 .Ar number
169 of file names and exit.
170 .It Fl m
171 Use
172 .Xr mmap 2
173 instead of the
174 .Xr stdio 3
175 library.
176 This is the default behavior
177 and is faster in most cases.
178 .It Fl s
179 Use the
180 .Xr stdio 3
181 library instead of
182 .Xr mmap 2 .
183 .El
184 .Sh ENVIRONMENT
185 .Bl -tag -width LOCATE_PATH -compact
186 .It Pa LOCATE_PATH
187 path to the locate database if set and not empty, ignored if the
188 .Fl d
189 option was specified.
190 .El
191 .Sh FILES
192 .Bl -tag -width /etc/periodic/weekly/310.locate -compact
193 .It Pa /var/db/locate.database
194 locate database
195 .It Pa /usr/libexec/locate.updatedb
196 Script to update the locate database
197 .It Pa /etc/periodic/weekly/310.locate
198 Script that starts the database rebuild
199 .El
200 .Sh SEE ALSO
201 .Xr find 1 ,
202 .Xr whereis 1 ,
203 .Xr which 1 ,
204 .Xr fnmatch 3 ,
205 .Xr locate.updatedb 8
206 .Rs
207 .%A Woods, James A.
208 .%D 1983
209 .%T "Finding Files Fast"
210 .%J ";login"
211 .%V 8:1
212 .%P pp. 8-10
213 .Re
214 .Sh HISTORY
215 The
216 .Nm
217 command first appeared in
218 .Bx 4.4 .
219 Many new features were
220 added in
221 .Fx 2.2 .
222 .Sh BUGS
223 The
224 .Nm
225 program may fail to list some files that are present, or may
226 list files that have been removed from the system.
227 This is because
228 locate only reports files that are present in the database, which is
229 typically only regenerated once a week by the
230 .Pa /etc/periodic/weekly/310.locate
231 script.
232 Use
233 .Xr find 1
234 to locate files that are of a more transitory nature.
235 .Pp
236 The
237 .Nm
238 database is typically built by user
239 .Dq nobody
240 and the
241 .Xr locate.updatedb 8
242 utility skips directories
243 which are not readable for user
244 .Dq nobody ,
245 group
246 .Dq nobody ,
247 or
248 world.
249 For example, if your HOME directory is not world-readable,
250 .Em none
251 of your files are
252 in the database.
253 .Pp
254 The
255 .Nm
256 database is not byte order independent.
257 It is not possible
258 to share the databases between machines with different byte order.
259 The current
260 .Nm
261 implementation understands databases in host byte order or
262 network byte order if both architectures use the same integer size.
263 So on a
264 .Fx Ns /i386
265 machine
266 (little endian), you can read
267 a locate database which was built on SunOS/sparc machine
268 (big endian, net).
269 .Pp
270 The
271 .Nm
272 utility does not recognize multibyte characters.