LOCATE_PATH
path to the locate database if set and not empty, ignored if the -d option was specified.
Find filenames quickly
locate [-0Scims]
[-l
limit]
[-d
database]
pattern ...
The locate program searches a database for all pathnames which match the specified pattern. The database is recomputed periodically (usually weekly or daily), and contains the pathnames of all files which are publicly accessible.
Shell globbing and quoting characters “(*”, “?”, “\”, “[” and “]”) may be used in pattern, although they will have to be escaped from the shell. Preceding any character with a backslash (“\”) eliminates any special meaning which it may have. The matching differs in that no characters must be matched explicitly, including slashes (“/”).
As a special case, a pattern containing no globbing characters (“foo”) is matched as though it were “*foo*”.
Historically, locate only stored characters between 32 and 127. The current implementation stores any character except newline (‘\n’) and NUL (‘\0’). The 8-bit character support does not waste extra space for plain ASCII file names. Characters less than 32 or greater than 127 are stored in 2 bytes.
The following options are available:
-0
Print pathnames separated by an ASCII NUL character (character code 0) instead of default NL (newline, character code 10).
-S
Print some statistics about the database and exit.
-c
Suppress normal output; instead print a count of matching file names.
-d database
Search in database instead of the default file name database. Multiple -d options are allowed. Each additional -d option adds the specified database to the list of databases to be searched.
The option database may be a colon-separated list of databases. A single colon is a reference to the default database.
$ locate -d $HOME/lib/mydb: foo
will first search string “foo” in $HOME/lib/mydb and then in /var/db/locate.database.
$ locate -d $HOME/lib/mydb::/cdrom/locate.database foo
will first search string “foo” in $HOME/lib/mydb and then in /var/db/locate.database and then in /cdrom/locate.database.
$ locate -d db1 -d db2 -d db3 pattern
is the same as
$ locate -d db1:db2:db3 pattern
or
$ locate -d db1:db2 -d db3 pattern
If - is given as the database name, standard input will be read instead. For example, you can compress your database and use:
$ zcat database.gz | locate -d - pattern
This might be useful on machines with a fast CPU and little RAM and slow I/O. Note: you can only use one pattern for stdin.
-i
Ignore case distinctions in both the pattern and the database.
-l number
Limit output to number of file names and exit.
LOCATE_PATH
path to the locate database if set and not empty, ignored if the -d option was specified.
/var/db/locate.database
locate database
/usr/libexec/locate.updatedb
Script to update the locate database
/System/Library/LaunchDaemons/com.apple.locate.plist
Job that starts the database rebuild
163 releases since Mac OS X 10.0; the text changed 3 times.
-0 since Mac OS X 10.4.11.ppc;
-S since Mac OS X 10.4.11.ppc;
-c since Mac OS X 10.4.11.ppc;
-d since Mac OS X 10.4.11.ppc;
-i since Mac OS X 10.4.11.ppc;
-l since Mac OS X 10.4.11.ppc;
-m since Mac OS X 10.4.11.ppc;
-s since Mac OS X 10.4.11.ppc.