LinuxCommandLibrary

mlocate

finds files by searching a pre-built database rather than scanning

TLDR

Find files by name

$ locate [pattern]
copy
Case-insensitive search
$ locate -i [pattern]
copy
Update database
$ sudo updatedb
copy
Show only existing files
$ locate -e [pattern]
copy
Limit results
$ locate -l [10] [pattern]
copy
Count matches
$ locate -c [pattern]
copy

SYNOPSIS

locate [options] pattern...

DESCRIPTION

mlocate (merging locate) finds files by searching a pre-built database rather than scanning the filesystem. This makes searches extremely fast.
The database is typically updated daily by cron, or manually with updatedb.

PARAMETERS

-i, --ignore-case

Case-insensitive match.
-l n, --limit n
Limit output to n entries.
-c, --count
Print count only.
-e, --existing
Only existing files.
-b, --basename
Match basename only.
-r, --regexp
Use regex pattern.
-d path
Use specific database.

DATABASE

$ Default: /var/lib/mlocate/mlocate.db
Config:  /etc/updatedb.conf

# Update database
sudo updatedb
copy

CAVEATS

Database may be outdated. New files won't appear until updatedb runs. Some paths excluded by default. Requires updatedb for fresh results.

HISTORY

mlocate was created by Miloslav Trmač as an improvement over GNU locate, using a more efficient database format that tracks file changes.

SEE ALSO

updatedb(8), find(1), fd(1), plocate(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community