1locate(1) General Commands Manual locate(1)
2
3
4
6 locate - find files by name
7
8
10 locate [OPTION]... PATTERN...
11
12
14 locate reads one or more databases prepared by updatedb(8) and writes
15 file names matching at least one of the PATTERNs to standard output,
16 one per line.
17
18 If --regex is not specified, PATTERNs can contain globbing characters.
19 If any PATTERN contains no globbing characters, locate behaves as if
20 the pattern were *PATTERN*.
21
22 By default, locate does not check whether files found in database still
23 exist (but it does require all parent directories to exist if the data‐
24 base was built with --require-visibility no). locate can never report
25 files created after the most recent update of the relevant database.
26
27
29 locate exits with status 0 if any match was found or if locate was
30 invoked with one of the --limit 0, --help, --statistics or --version
31 options. If no match was found or a fatal error was encountered,
32 locate exits with status 1.
33
34 Errors encountered while reading a database are not fatal, search con‐
35 tinues in other specified databases, if any.
36
37
39 -A, --all
40 Print only entries that match all PATTERNs instead of requiring
41 only one of them to match.
42
43
44 -b, --basename
45 Match only the base name against the specified patterns. This
46 is the opposite of --wholename.
47
48
49 -c, --count
50 Instead of writing file names on standard output, write the num‐
51 ber of matching entries only.
52
53
54 -d, --database DBPATH
55 Replace the default database with DBPATH. DBPATH is a :-sepa‐
56 rated list of database file names. If more than one --database
57 option is specified, the resulting path is a concatenation of
58 the separate paths.
59
60 An empty database file name is replaced by the default database.
61 A database file name - refers to the standard input. Note that
62 a database can be read from the standard input only once.
63
64
65 -e, --existing
66 Print only entries that refer to files existing at the time
67 locate is run.
68
69
70 -L, --follow
71 When checking whether files exist (if the --existing option is
72 specified), follow trailing symbolic links. This causes broken
73 symbolic links to be omitted from the output.
74
75 This is the default behavior. The opposite can be specified
76 using --nofollow.
77
78
79 -h, --help
80 Write a summary of the available options to standard output and
81 exit successfully.
82
83
84 -i, --ignore-case
85 Ignore case distinctions when matching patterns.
86
87
88 -l, --limit, -n LIMIT
89 Exit successfully after finding LIMIT entries. If the --count
90 option is specified, the resulting count is also limited to
91 LIMIT.
92
93
94 -m, --mmap
95 Ignored, for compatibility with BSD and GNU locate.
96
97
98 -P, --nofollow, -H
99 When checking whether files exist (if the --existing option is
100 specified), do not follow trailing symbolic links. This causes
101 broken symbolic links to be reported like other files.
102
103 This is the opposite of --follow.
104
105
106 -0, --null
107 Separate the entries on output using the ASCII NUL character
108 instead of writing each entry on a separate line. This option
109 is designed for interoperability with the --null option of GNU
110 xargs(1).
111
112
113 -S, --statistics
114 Write statistics about each read database to standard output
115 instead of searching for files and exit successfully.
116
117
118 -q, --quiet
119 Write no messages about errors encountered while reading and
120 processing databases.
121
122
123 -r, --regexp REGEXP
124 Search for a basic regexp REGEXP. No PATTERNs are allowed if
125 this option is used, but this option can be specified multiple
126 times.
127
128
129 --regex
130 Interpret all PATTERNs as extended regexps.
131
132
133 -s, --stdio
134 Ignored, for compatibility with BSD and GNU locate.
135
136
137 -V, --version
138 Write information about the version and license of locate on
139 standard output and exit successfully.
140
141
142 -w, --wholename
143 Match only the whole path name against the specified patterns.
144
145 This is the default behavior. The opposite can be specified
146 using --basename.
147
148
150 To search for a file named exactly NAME (not *NAME*), use
151 locate -b '\NAME'
152 Because \ is a globbing character, this disables the implicit replace‐
153 ment of NAME by *NAME*.
154
155
157 /var/lib/mlocate/mlocate.db
158 The database searched by default.
159
160
162 LOCATE_PATH
163 Path to additional databases, added after the default database
164 or the databases specified using the --database option.
165
166
168 The order in which the requested databases are processed is unspeci‐
169 fied, which allows locate to reorder the database path for security
170 reasons.
171
172 locate attempts to be compatible to slocate (without the options used
173 for creating databases) and GNU locate, in that order. This is the
174 reason for the impractical default --follow option and for the confus‐
175 ing set of --regex and --regexp options.
176
177 The short spelling of the -r option is incompatible to GNU locate,
178 where it corresponds to the --regex option. Use the long option names
179 to avoid confusion.
180
181 The LOCATE_PATH environment variable replaces the default database in
182 BSD and GNU locate, but it is added to other databases in this imple‐
183 mentation and slocate.
184
185
187 Miloslav Trmac <mitr@redhat.com>
188
189
191 updatedb(8)
192
193
194
195mlocate Sep 2012 locate(1)