← 返回命令列表

Linux command

plocate 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Find files by name

plocate [filename]

Case-insensitive search

plocate -i [filename]

Count matches

plocate -c [pattern]

Limit results

plocate -l [10] [pattern]

Use regex pattern

plocate --regex "[.*\.pdf$]"

Show only existing files

plocate -e [pattern]

Show database statistics

plocate -S

Update the database

sudo updatedb

说明

plocate is a much faster replacement for mlocate, finding files by searching a pre-built database rather than scanning the filesystem in real-time. The database (updated by updatedb, typically via cron) indexes all filenames on the system. Searches are essentially instant regardless of filesystem size - even with millions of files. Pattern matching is substring by default: "foo" matches "/path/to/foobar.txt". Use --regex for precise matching or -b to match only the basename. Case sensitivity can be toggled with -i. The -e option verifies files still exist before displaying, filtering out stale entries from recently deleted files. This adds overhead but ensures accurate results. plocate uses a more compact database format than mlocate and employs posting lists for fast searching. The same updatedb database works with both tools.

参数

-i, --ignore-case
Case-insensitive matching.
-c, --count
Print count of matches.
-l _N_, --limit _N_
Limit output to N entries.
-e, --existing
Only show existing files.
-b, --basename
Match only basename, not full path.
-w, --wholename
Match full path (default).
-r, --regex
Use POSIX extended regex.
--regex
Pattern is a regular expression.
-d _PATH_, --database _PATH_
Use specified database file.
-0, --null
Null-terminate output.
-S, --statistics
Show database statistics.
-q, --quiet
Quiet mode, exit status only.
-N, --literal
Match pattern literally.

FAQ

What is the plocate command used for?

plocate is a much faster replacement for mlocate, finding files by searching a pre-built database rather than scanning the filesystem in real-time. The database (updated by updatedb, typically via cron) indexes all filenames on the system. Searches are essentially instant regardless of filesystem size - even with millions of files. Pattern matching is substring by default: "foo" matches "/path/to/foobar.txt". Use --regex for precise matching or -b to match only the basename. Case sensitivity can be toggled with -i. The -e option verifies files still exist before displaying, filtering out stale entries from recently deleted files. This adds overhead but ensures accurate results. plocate uses a more compact database format than mlocate and employs posting lists for fast searching. The same updatedb database works with both tools.

How do I run a basic plocate example?

Run `plocate [filename]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -i, --ignore-case do in plocate?

Case-insensitive matching.