kokoe blog

技術メモブログ

memo: find/grepチートシート

# 同ディレクトリ以下(再帰)の拡張子htmlファイルで、ファイル内にhogeがあるファイルを検索
$ find ./ -name "*.html" | xargs grep "hoge"

# 同ディレクトリ以下(再帰)のファイル(notディレクトリ)で、ファイル内にhogeがあるファイルのフルパスを表示
$ find ./ -type f | xargs grep -ril "hoge"

# 同ディレクトリ以下(再帰)の拡張子cssファイルで、各ファイルにimportantが何個出現するかresult.txtに出力する
$ find ./ -name "*.css" | xargs grep -c "important" > result.txt

# node_modulesディレクトリをfindの対象外にする
$ find ./ -type f -not -path "./node_modules/*" | xargs grep "axios"