TIPS/sh/findによるgrep

Last-modified: 2006-11-14 (火) 20:50:16

findコマンドで-execオプションにgrepを指定する

find . -name "*.[hc]" -exec grep -H hogehoge {} ";"
find . -name "*.[hc]" -exec grep -H hogehoge {} \;
  • .は場所を指定。その場所以下をサイクリックに検索
  • -nameは探すファイル指定
  • -execでコマンド指定
  • -Hはgrep でファイル名を出力する
  • {]でfind . -name "*.[hc]"の出力を入力する
  • ";"でコマンドの終わり(command terminate)