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?

More than 5 years have passed since last update.

find コマンドのよく使う式まとめ

Last updated at Posted at 2019-11-23

CentOS 7 で確認。find のバージョンは 4.5.11。

ファイル・ディレクトリ名で検索

-name '<ファイル名>'

ワイルドカード(*?[])を使用できる。その際は引用符を忘れずに。
-iname は大文字と小文字を区別しない。

パスを正規表現で検索

-regex '<パターン>'

-iregex は大文字と小文字を区別しない。

ファイル種別で検索

-type <タイプ>

タイプは、通常ファイルなら f、ディレクトリなら d

過去 n 分以内に変更されたファイルを検索

-mmin -n

過去 n*24 時間以内に変更されたファイルを検索

-mtime -n

見つかったファイルのそれぞれに対してコマンドを 1 度ずつ実行

-exec <コマンド> \;

コマンドの中に {} と記述すると、ファイルのパスに置き換えられる。

見つかったファイルのすべてに対してコマンドを 1 度だけ実行

-exec <コマンド> {} +

{} がファイルのパスに置き換えられる。

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?