I am searching through a Ruby on Rails application for a word using grep
on OSX, and I would like to exclude directories that match a certain pattern.
I am using the following command:
grep -inRw -E 'direct' . --exclude-dir -E 'git|log|asset'
This command is not doing what I thought it would do. Here is how I thought it would work:
- i - case insensitive search
- n - print line number in which pattern is found
- R - search recursively
- w - I only want whole words - i.e., match "direct" but not "directory"
- -E - use extended regular expression
- 'direct' - the regular expression I want to match
- . - search in the current directory
- --exclude-dir -E 'git|log|asset' - exclude directories that match git or log or asset.
In terms of the exclude directories, the command still ends up searching in the './git' and './log' directories, as well as in './app/assets'
I'm obviously lacking a fundamental piece of knowledge, but I do not know what it is.