それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

grep で特定のディレクトリを外す/無視するフォルダを指定

grep で特定のディレクトリを除外する。

grep で指定したディレクトリ以外で検索する

‘--exclude-dir=dir’
    Exclude directories matching the pattern dir from recursive directory searches.

で、コレを使って、次のようにコマンドを実行すれば、ディレクトリ除いた結果を取得できる

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search

だそうです。

include のディレクトリは使うことが殆ど無いだろうけど、exclude でディレクトリを除外するのはメッチャ使いそう。

logs とか、.git を除外してると便利そうですねー

参考資料

http://stackoverflow.com/questions/6565471/how-can-i-exclude-directories-from-grep-r

See File and Directory Selection for description and grep --exclude/--include syntax (do not grep through certain files) for a bit more information regarding syntax and usage.

関連資料

特定の拡張子(*.php)のファイルだけをGrepして検索したい。 - それマグで!

grepで逆検索 (マッチするモノを除外)でマッチしないものを探す - それマグで!