Grepping through repo directories (aka the ".svn/" problem)

It's super annoying when you're looking for a string in your code, so you do a recursive grep, only to get a ton of matches within svn's ".svn" directories.

Here's a solution:

Inside your ~/.bash_profile, insert this line:

  1. alias rgrep="find . -follow \( -name ".svn" \) -prune -o -print | xargs grep -Hn"

Save it, then log out and back in. Now instead of

  1. grep -ir "sprintf" *

do
  1. rgrep sprintf

Cake!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <embed> <blockquote>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <csss>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options