I'm attempting to setup my GREP_OPTIONS
to always exclude certain directories (eg target/classes
). I'm specifically trying to get this to work for recursive greps. Using --exclude-dir=target/classes
works great when the current directory contains target/classes
, but not so when I'm in the parent directory. My current solution requires me to set both --exclude-dir=target/classes
and --exclude-dir=*/target/classes
. I'm looking for a more direct solution, which I assume will involve a regex. I've tried --exclude-dir=(*/)?target/classes
and other permutations, but I can't get it to work.
Yes yes, I'm sure this can be accomplished with other tools (ie find, awk, etc), but I'd really like to keep this confined (if possible) to the GREP_OPTIONS
solution.
Here is a working example tested, be careful with syntax and not to typo:
root/dspace# grep -r --exclude-dir={log,assetstore} "creativecommons.org"
Above i grep for text "creativecommons.org" in current directory "dspace" and exclude dirs {log,assetstore}.
Done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.