Using ‘grep’ with Subversion

I use ‘grep’ alot, but it false positives when searching in a Subversion working copy. So I’m using the ‘-r’ flag to recursive search for the phrase ‘quick brown fox’:

$ grep -r 'quick brown fox' *
app/controllers/users_controller.php: quick brown fox
app/controllers/.svn/text-base/users_controller.php.svn-base: quick brown fox

This is only a minor annoyance if there are just two entries, but often that’s not the case. The solution is to add the ‘–exclude-dir=.svn’ flag. But the extra characters causes unnecessary fatigue on my fingers, so I’ve added an alias to my .bashrc file:

alias grep='grep --exclude-dir=.svn'

For maximum mileage, combine this with ‘-ir’:

alias grep='grep -ir --exclude-dir=.svn'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s