findとgrepを使うことでなにができるか
ディレクトリを指定して、再帰的にgrepすることができる
指定ディレクトリ配下の全ファイルにgrep
find /var/www/wordpress/ -type f | xargs grep '検索文字列'
指定ディレクトリ配下の指定した拡張子のファイルにgrep
find /var/www/wordpress/ \( -name \*.html -or -name \*.php \) -print | xargs grep '検索文字列'
- -printはフルパス出力をするオプション。findコマンドのデフォルトの挙動みたいなのであってもなくてもよさそう
- xargs が何をしているかは以下リンク
- https://albel06.hatenablog.com/entry/2018/10/21/211905 https://teratail.com/questions/25558
- https://techblog.kyamanak.com/entry/2018/02/12/202256