Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-01-2007, 06:56 AM   #1
LQ Newbie
Registered: Jul 2006
Posts: 8

Rep: Reputation: 0
Avoid .svn folder when using grep

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?
Old 06-01-2007, 07:33 AM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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.
Old 06-02-2007, 12:27 AM   #3
Registered: May 2006
Distribution: Fedora Core 6
Posts: 38

Rep: Reputation: 15
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.

Last edited by hradtke; 06-02-2007 at 11:00 AM.


grep, subversion, svn

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
anon svn read-only over apache: '.svn/entries': No such file hedpe Linux - Software 2 04-29-2009 05:31 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM
want to avoid 777 permission, but want to write on folder suruchiparimu Linux - Newbie 10 02-09-2006 03:25 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

All times are GMT -5. The time now is 08:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration