Grepping in your subversion working copies

Grepping is in a lot of cases a pain when your dealing with subversion directories..

I'm sure this doesn't cover all possible greps, but this at least works for the simple ones..

grep $* | grep -v ".svn"

Call this script for example "svngrep", give it executable permissions (chmod +x svngrep) and place it in a directory thats in your PATH variable (/bin).

Now, use svngrep as you would normally use grep..

Update: The anonymous posters script is way better (the first comment)

Web mentions


  • Anonymous

    This is a little more robust:

    find . -type d \( -name .svn -o -name ignore1 -o -name ignore2 \) -prune -o -type f -print0 |xargs -0r grep --color "$@"
  • Evert


    Great script!
  • Martin Jansen

    Martin Jansen

    ack automatically ignores .svn directories and is generally a neat litte tool:
  • ethan


    Sweet. Thanks.
  • Matthew Purdon

    Matthew Purdon

    If you are on a box that you haven't set up that script on, I like to use the following straight from the command line:

    $ find . -name "*.php" | xargs grep "search string"

    Not as nice as having the first comment script, but easy enough to remember without having to look it up.
  • Dagfinn Reiersøl

    Dagfinn Reiersøl

    There is also a script called wcgrep (
  • Amanda


    Hi, all. Nice site...I really like your site ! Good job man.h
  • Bush


  • Vince


    Just wanted to say hellou