<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zulius &#187; grep</title>
	<atom:link href="http://www.zulius.com/tag/grep/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zulius.com</link>
	<description>Advanced Application Development</description>
	<lastBuildDate>Mon, 30 Aug 2010 20:44:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Skip .svn directories when using grep</title>
		<link>http://www.zulius.com/how-to/grep-skip-svn-directories/</link>
		<comments>http://www.zulius.com/how-to/grep-skip-svn-directories/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 20:56:08 +0000</pubDate>
		<dc:creator>Tim White</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.zulius.com/?p=383</guid>
		<description><![CDATA[What You'll Need: grep 2.5.3+

I can't count how many times a day I use grep.  It is an indispensable tool for searching the contents of configuration files, data files, and source code.
One of the annoying side effects of grep is when searching a Subversion working copy recursively, all the hidden .svn directories also get [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 158px"><img alt="grep returns .svn metadata" src="/img/blog/title-image-grepSkipSvn.jpg" title="grep returns .svn metadata" width="148" height="110" /><p class="wp-caption-text">grep returns .svn metadata files</p></div>
<p><strong>What You'll Need:</strong><br /> <a href="http://www.gnu.org/software/grep/">grep 2.5.3+</a>
</p>
<p>I can't count how many times a day I use grep.  It is an indispensable tool for searching the contents of configuration files, data files, and source code.</p>
<p>One of the annoying side effects of grep is when searching a Subversion working copy recursively, all the hidden .svn directories also get searched.  This can yield a lot of false positive matches since these directories contain <a href="http://svn.collab.net/repos/svn/trunk/doc/user/svn-best-practices.html">"pristine copies of all version-controlled files"</a>.</p>
<p>If you've got grep 2.5.3 or higher, it's easy to ignore .svn directories with the "--exclude-dir" option:</p>
<pre class="brush: plain;">$ grep -r --exclude-dir='.svn' 'my search string' /some/directory</pre>
<p>But that's a lot to type in each time you want to search your source code.  To save keystrokes, try setting up an alias in your home directory's .bashrc file that utilizes the --exclude-dir option (for Mac, use your home directory's .profile file.).  I call mine <strong>devgrep</strong>:</p>
<pre class="brush: plain;">alias devgrep=&quot;grep --exclude-dir='.svn'&quot;</pre>
<p>After adding the alias, don't forget to source your .bashrc:</p>
<pre class="brush: plain;">$ source ~/.bashrc</pre>
<p>Now whenever you need to search a Subversion working copy recursively, use the new alias to skip .svn directories:</p>
<pre class="brush: plain;">$ devgrep -rin 'doctype' /var/www/html/templates
./foo.tpl:1:&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
./bar.tpl:1:&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
./baz.phtml:1:&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Frameset//EN&quot; &quot;http://www.w3.org/TR/html4/frameset.dtd&quot;&gt;</pre>
<p>You can also exclude file types when grep'ing.  If you're a vim user, it can be helpful to skip .swp files in your alias:</p>
<pre class="brush: plain;">alias devgrep=&quot;grep --exclude-dir='.svn' --exclude='*.swp'&quot;</pre>
<p>Yet another workaround would be to use <a href="http://betterthangrep.com/">ack</a> - a Perl based, juiced up version of grep with a lot more features.</p>
<img src="http://www.zulius.com/blog/?ak_action=api_record_view&id=383&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.zulius.com/how-to/grep-skip-svn-directories/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
