0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

よく忘れるfindコマンドの使い方メモ|削除・ファイル指定・typeオプション

Last updated at Posted at 2025-07-10

初めに

稀によく使うfindコマンド!
使うたび記憶が飛んで使い方を忘れます。
記事にしたら忘れないのではと思い記事にしました。

よく使うfindの基本形

find <検索する場所> -name 検索ファイル名

名前の文字列をキーにファイルやディレクトリを検索する。
(ディレクトリを再帰的に検索する。)

検索対象をファイルだけにしたい場合は、-type fを、
検索対象をディレクトリだけにしたい場合は、-type dを、コマンド末尾に追加する。

削除目的で使うときのfind

find <検索する場所> -name 検索ファイル名 -delete

deleteが使えない環境の場合はこっち。

find <検索する場所> -name 検索ファイル名 -exec rm -f {} +

削除はいろいろなコマンドがあり詳しい違いについては以下の記事を参考にする。
基本はdeleteでok。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?