<?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>Software Warlock &#187; grep</title>
	<atom:link href="http://softwareblog.morlok.net/tag/grep/feed/" rel="self" type="application/rss+xml" />
	<link>http://softwareblog.morlok.net</link>
	<description></description>
	<lastBuildDate>Sat, 10 Jul 2010 15:34:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Emulating grep with PowerShell</title>
		<link>http://softwareblog.morlok.net/2009/05/07/emulating-grep-with-powershell/</link>
		<comments>http://softwareblog.morlok.net/2009/05/07/emulating-grep-with-powershell/#comments</comments>
		<pubDate>Thu, 07 May 2009 20:36:58 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=211</guid>
		<description><![CDATA[
I&#8217;m a big fan of PowerShell with it&#8217;s nifty object pipeline, but there are some quick and dirty tasks it could make easier.  As and example, I was looking for a way to recursively search through directories, looking at the contents of files for a specific string.


Accomplishing this took a little poking around the [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;m a big fan of PowerShell with it&#8217;s nifty object pipeline, but there are some quick and dirty tasks it could make easier.  As and example, I was looking for a way to recursively search through directories, looking at the contents of files for a specific string.
</p>
<p>
Accomplishing this took a little poking around the Internet, but ultimately I found a great <a href="http://www.mickelson.org/2007/12/06/emulating-grep-in-powershell/">blog post</a> describing how to do it.  You need to to use a combination of <tt>get-childitem</tt> (abbreviated <tt>gci</tt>) and <tt>select-string</tt>.  From Marshall&#8217;s post:</p>
<p>The grep command <tt style="color:green;">grep -R "mypattern" *.cpp</tt> can be translated to the PowerShell command:</p>
<p><tt style="color:green;">gci . --include *.cpp -recurse | select-string -pattern "mypattern" -caseSensitive</tt></p>
<p>Note that &#8220;.&#8221; can be replaced with an arbitrary path as opposed to the current directory and you might want to leave off <tt>-caseSensitive</tt> if you don&#8217;t care about case.  You can also omit <tt>--include *.cpp</tt> to include all files.</p>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2009/05/07/emulating-grep-with-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
