LoginSignup
0
0

More than 5 years have passed since last update.

ディレクトリ下にあるすべてのテキストファイルから、文字列hogeを含むファイルを抜き出す

Posted at

いつも忘れる

find ./ type f -name "*.txt" | xargs grep "hoge"

findコマンドで拡張子が"txt"のファイルを探す。
type -f で、実体ファイルを対象とする。
./ で、ディレクトリ配下を検索する。

findコマンドで検索した結果をxargsに引き渡す
先に検索した結果「ディレクトリ以下の "*.txt" ファイル」の中からhogeという文字列を含むものを、grepでピックアップする。

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