LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices



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

Rep: Reputation: 0
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?
 
Old 06-01-2007, 08:33 AM   #2
b0uncer
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, 01:27 AM   #3
hradtke
Member
 
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 12:00 PM.
 
  


Reply

Tags
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 06:31 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 05:56 AM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 12:36 PM
want to avoid 777 permission, but want to write on folder suruchiparimu Linux - Newbie 10 02-09-2006 04:25 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


All times are GMT -5. The time now is 10:51 PM.

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