Exclude .svn directories from grep [duplicate] Exclude .svn directories from grep [duplicate] bash bash

Exclude .svn directories from grep [duplicate]


If you have GNU Grep, it should work like this:

grep --exclude-dir=".svn"

If happen to be on a Unix System without GNU Grep, try the following:

grep -R "whatever you like" *|grep -v "\.svn/*" 


For grep >=2.5.1a

You can put this into your environment (e.g. .bashrc)

export GREP_OPTIONS='--exclude-dir=".svn"'

PS: thanks to Adrinan, there are extra quotes in my version:

export GREP_OPTIONS='--exclude-dir=.svn'

PPS: This env option is marked for deprecation: https://www.gnu.org/software/grep/manual/html_node/Environment-Variables.html "As this causes problems when writing portable scripts, this feature will be removed in a future release of grep, and grep warns if it is used. Please use an alias or script instead."


If you use ack (a 'better grep') it will handle this automatically (and do a lot of other clever things too!). It's well worth checking out.