0
1

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 1 year has passed since last update.

[Linux] よく使うfindコマンドオプション

Last updated at Posted at 2022-07-21

概要

よく使うファイル検索だけをまとめた。
これらは、VSCodeなどの統合開発環境を使うことのできない環境では、大変お世話になります。

色々なoptionを網羅的に書いてあるサイトもあるが、どれが自分にとって必要なコマンドなのかわかりにくい。

基本的にはこれだけで十分。

検索コマンド

1. ファイル名を再帰的に検索

hogeという文字列を含むファイル名のファイルを検索

$ find ./ -name *hoge*

2. directory名を再帰的に検索

hogeという文字列を含むディレクトリ名のディレクトリを検索

$ find ./ -name *hoge* -type d

3. 指定したディレクトリ内のファイル内文字列を検索

./dirディレクトリの中にあるファイルの内、
ファイル内にhogeという文字列を含むファイルを検索

$ find ./dir -type f -print | xargs grep -n hoge

参考

find コマンド以外にも便利なコマンドや記事をメモしておく

ディレクトリを zip ファイルに格納

$ zip archive -r target_directory

複数ファイルの拡張子をまとめて1発置換

0
1
1

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?