Assume unistd.h is present - avoid using HAVE_UNISTD_H
[findutils.git] / locate / locate.1
blob4cc0ab6ca5520a60dc4176c97dc9f5396dba4d32
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 POSIX
147 extended regular expression, as opposed to a glob pattern.  Filenames
148 whose full paths match the specified regular expression are printed
149 (or, in the case of the -c option, counted).  If you wish to anchor
150 your regular expression at the ends of the full path name, then as is
151 usual with regular expressions, you should use the characters ^ and $
152 to signify this.   Newline is not considered to be special.
154 .I "\-s, \-\-stdio"
155 Accepted but does nothing, for compatibility with BSD 
156 .BR locate .
158 .I "\-S, \-\-statistics"
159 Print various statistics about each locate database and then exit
160 without performing a search, unless non-option arguments are given.
161 For compatibility with BSD, \-S is accepted as a synonym
162 for \-\-statistics.
164 .I "\-\-help"
165 Print a summary of the options to
166 .B locate
167 and exit.
169 .I "\-\-version"
170 Print the version number of
171 .B locate
172 and exit.
173 .SH ENVIRONMENT
175 .B LOCATE_PATH
176 Colon-separated list of databases to search.  If the value has a
177 leading or trailing colon, or has two colons in a row, you may get
178 results that vary between different versions of 
179 .BR locate .
181 .SH "SEE ALSO"
182 \fBfind\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1), \fBxargs\fP(1),
183 \fBglob\fP(3),\fregex\fP(7),
184 \fBFinding Files\fP (on-line in Info, or printed)
185 .SH "BUGS"
187 The locate database correctly handles filenames containing newlines,
188 but only if the system's sort command has a working
189 .I \-z
190 option.  If you suspect that 
191 .B locate
192 may need to return filenames containing newlines, consider using its
193 .I \-\-null 
194 option.
196 The best way to report a bug is to use the form at
197 http://savannah.gnu.org/bugs/?group=findutils.  
198 The reason for this is that you will then be able to track progress in
199 fixing the problem.   Other comments about \fBlocate\fP(1) and about
200 the findutils package in general can be sent to the 
201 .I bug-findutils
202 mailing list.  To join the list, send email to 
203 .IR bug-findutils-request@gnu.org .