locate

ファイルとディレクトリ

書き方

locate [name]

あらかじめ作った索引を引くので即答しますが、最後の updatedb 以降にできたファイルは見えません。

よく使うオプション

オプション意味
-iIgnore case
-lStop after N results
-cPrint only how many matched
-bGNU mlocate: match the file name, not the whole path
-rGNU: read the pattern as a regular expression
-eGNU: skip entries that no longer exist on disk

locate -i nginx.conf

Finds the config anywhere on disk, instantly.

sudo updatedb

Rebuilds the index so new files can be found.

移したり消したり探したりするものです。聞き返してくれない命令が混ざっているので、-i を付ける癖が手を守ります。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. locate は何をしますか。

あらかじめ作った索引を引くので即答しますが、最後の updatedb 以降にできたファイルは見えません。

Q. どう打ちますか。

locate [name] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは6個です。全部は man locate にあります。このコマンドはファイルとディレクトリの仲間です。

関連するコマンド

man ページ: man locate