LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Avoid .svn folder when using grep (https://www.linuxquestions.org/questions/linux-general-1/avoid-svn-folder-when-using-grep-558274/)

jostmart 06-01-2007 06:56 AM

Avoid .svn folder when using grep
 
Hi
When I am using grep f.ex. "grep -ire 'something' ." and theres an .svn folder, grep will go trough that folder also. How can I exclude folders and/or files?

b0uncer 06-01-2007 07:33 AM

Can't remember if grep does it someway, but first thing I'd do is first use find to create a list of the directories you want, excluding those you don't, and then using that as a start-off for grep.

hradtke 06-02-2007 12:27 AM

This should work:

find . -path "*.svn" -prune -o -exec grep -ie "something" {} \;

The -prune command is saying to ignore that path. We use the * so as you recurse through the tree with find, we still omit the .svn dir. Note that you do not need to recurse through each directory with grep in this case.


All times are GMT -5. The time now is 01:32 AM.