-
-
Save a1phanumeric/5346170 to your computer and use it in GitHub Desktop.
grep -r --color --exclude-dir={custom,lib,scripts} --exclude={*.xml,error_log} "beta" . |
@c9n (or any OS X user)- If you use Homebrew, you can get the standard GNU grep with:
brew install grep --with-default-names
If you want to go "all-in" on GNU tools see: Install and Use GNU Command Line Tools on Mac OS X
I was tired of always typing --exclude-dir=
and wrote a small wrapper for grep that reads excludes from config files. Maybe others will find it helpful: https://github.com/gwgundersen/gp
@gwgundersen gp sounds nice, but it is very similar to git grep
in practice.
The --exclude-dir={...}
now works on OSX, as far as I can tell. I didn't manually override it with brew as previously suggested, and this is a new machine on El Capitan.
Thanks! First result for "grep ignore multiple directories" ^_^
Much appreciated!
Just a heads up if you didn't notice that you can't have spaces between those folders after the comma. It throws a parse error.
Thanks!!!
"The --exclude-dir={...} now works on OSX, as far as I can tell." from @jpucinno same for me.
on OSX it works
Gold! thanks buddy!
Awesome, Thanks!
This works both on Mac OS and Linux :)
# --color: highlight matched string
# -r: recursive search
# -i: ignore case
# --exclude: exclude specified files
# --exclude-dir: exclude specified dir
grep --color -r -i "foo\|bar" --exclude={\*.csv,\*.txt} --exclude-dir={.git,.idea,vendor} .
muchos gracias.
won't work on Mac OS X