locate flags & options

Basic usage

Find files matching a pattern. Searches a pre-built database, so it's faster than find.

locate nginx.conf

-i, --ignore-case

Case-insensitive search.

locate -i readme.md

-c, --count

Print only the count of matching entries.

locate -c "*.log"

-l, --limit

Limit the number of results.

locate -l 10 "*.py"

-r, --regexp

Use a POSIX regular expression instead of a glob pattern.

locate -r '/etc/.*\.conf$'

-e, --existing

Only show files that currently exist on disk.

locate -e "*.bak"

-b, --basename

Match only the filename, not the full path.

locate -b "Makefile"

Update the database

The database must be updated to find new files. Requires root.

sudo updatedb