<?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>Virtual Kingdoms &#187; Linux</title>
	<atom:link href="http://virtualkingdoms.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://virtualkingdoms.net</link>
	<description></description>
	<lastBuildDate>Fri, 07 Oct 2011 02:16:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Customizing Grep</title>
		<link>http://virtualkingdoms.net/2007/12/customizing-grep/</link>
		<comments>http://virtualkingdoms.net/2007/12/customizing-grep/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 04:37:18 +0000</pubDate>
		<dc:creator>eremite</dc:creator>
				<category><![CDATA[Open Source / Free Software]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://virtualkingdoms.net/2007/12/21/customizing-grep/</guid>
		<description><![CDATA[Here&#8217;s a script that I wrote to help me find things at work. #!/bin/bash if [ ! -n "$1" ] then echo "Usage: `basename $0` pattern [optional args to grep]" echo "e.g. grepit findme -i" echo exit 1 fi if &#8230; <a href="http://virtualkingdoms.net/2007/12/customizing-grep/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a script that I wrote to help me find things at work.</p>
<p><code><br />
#!/bin/bash</p>
<p>if [ ! -n "$1" ]<br />
then<br />
  echo "Usage: `basename $0` pattern [optional args to grep]"<br />
  echo "e.g. grepit findme -i"<br />
  echo<br />
  exit 1<br />
fi</p>
<p>if [ ! -n "$2" ]<br />
then<br />
  grep -r --exclude='*.log' "$1" * | grep -v '/.svn/'<br />
else<br />
  grep -r "$2" --exclude='*.log' "$1" * | grep -v '/.svn/'<br />
fi<br />
</code></p>
<p>Basically I just got tired of always specifying the recursive option to grep and having to exclude svn and log files (because they were redundant or took too long to search). I also found that sometimes I wanted to add additional arguments (like -i for ignoring case or -n for line numbers). So now when I change a function in one file and want to find every place that function was used I simply do a</p>
<p><code><br />
grepit function_name<br />
</code></p>
<p>P.S. Let me know if you know a good way to strip leading whitespace from the results.</p>
]]></content:encoded>
			<wfw:commentRss>http://virtualkingdoms.net/2007/12/customizing-grep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

