Smart grep with SVN

Posted on Sunday March 06, 2011 / by Eric Potvin

Looking for code in PHP files with grep is great! Grep is one of the best command of Linux to find what you need quickly.

But if you are like me, you don't want to see what's in the SVN repository hidden folder and/or the smarty cached files.

To remove SVN repository files, you need to add to the grep:

grep -v "\.svn"

Now to remove the smarty files:

grep -v %%

Now let's add some color (mandatory):

grep "search_criteria" --color

Now the final command:

grep -r "search_criteria" /home/user/path/* | grep -v "\.svn" | grep -v %% | grep "search_criteria" --color