LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

locate

searches a prebuilt database to find files matching a pattern

TLDR

Find files by pattern
$ locate "[pattern]"
copy
Find case-insensitive
$ locate -i "[pattern]"
copy
Find by exact filename (basename only)
$ locate -b "\[filename]"
copy
Limit output to a specific number of results
$ locate -l [10] "[pattern]"
copy
Count the number of matching entries
$ locate -c "[pattern]"
copy
Display database statistics
$ locate -S
copy
Update the database
$ sudo updatedb
copy

SYNOPSIS

locate [options] pattern...

DESCRIPTION

locate searches a prebuilt database to find files matching a pattern, making it much faster than find for simple filename searches. The database is typically updated daily by a cron job.

PARAMETERS

-i, --ignore-case

Case-insensitive search
-l, --limit N
Limit output to N entries
-c, --count
Print count of matches
-e, --existing
Only print existing files
-b, --basename
Match only basename
-r, --regexp
Use basic regex pattern
--regex
Use extended regex pattern
-d, --database DBPATH
Search in specified database instead of the default
-S, --statistics
Print statistics about each database and exit
-w, --wholename
Match against the whole path name (default behavior)

CAVEATS

Database is updated periodically, so recently created files may not be found. Run `updatedb` to refresh the database manually.

SEE ALSO

find(1), updatedb(1), mlocate(1), plocate(1)

Copied to clipboard
Kai