- Look for pattern in the database. Note: the database is recomputed periodically (usually weekly or daily):locate [pattern]- Look for a file by its exact filename (a pattern containing no globbing characters is interpreted as `*pattern*`):locate */[filename]- Recompute the database. You need to do it if you want to find recently added files:sudo updatedb
locate [OPTION]... PATTERN...
locate reads one or more databases prepared by updatedb(8) and writes file names matching at least one of the PATTERNs to standard output, one per line.
If --regex is not specified, PATTERNs can contain globbing characters. If any PATTERN contains no globbing characters, locate behaves as if the pattern were *PATTERN*.
By default, locate does not check whether files found in database still exist (but it does require all parent directories to exist if the database was built with --require-visibility no). locate can never report files created after the most recent update of the relevant database.
locate exits with status 0 if any match was found or if locate was invoked with one of the --limit 0, --help, --statistics or --version options. If no match was found or a fatal error was encountered, locate exits with status 1.
Errors encountered while reading a database are not fatal, search continues in other specified databases, if any.
An empty database file name is replaced by the default database. A database file name - refers to the standard input. Note that a database can be read from the standard input only once.
This is the default behavior. The opposite can be specified using --nofollow.
This is the opposite of --follow.
This is the default behavior. The opposite can be specified using --basename.
To search for a file named exactly NAME (not *NAME*), use
The order in which the requested databases are processed is unspecified, which allows locate to reorder the database path for security reasons.
locate attempts to be compatible to slocate (without the options used for creating databases) and GNU locate, in that order. This is the reason for the impractical default --follow option and for the confusing set of --regex and --regexp options.
The short spelling of the -r option is incompatible to GNU locate, where it corresponds to the --regex option. Use the long option names to avoid confusion.
The LOCATE_PATH environment variable replaces the default database in BSD and GNU locate, but it is added to other databases in this implementation and slocate.
Miloslav Trmac <email@example.com>