<?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>rajaseelan.com &#187; line numbers</title>
	<atom:link href="http://rajaseelan.com/tag/line-numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://rajaseelan.com</link>
	<description>junk food for the brain ...</description>
	<lastBuildDate>Tue, 28 Jul 2009 16:37:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to search / grep for more than one word at a time</title>
		<link>http://rajaseelan.com/2009/07/04/how-to-search-grep-for-more-than-one-word-at-a-time/</link>
		<comments>http://rajaseelan.com/2009/07/04/how-to-search-grep-for-more-than-one-word-at-a-time/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 18:14:32 +0000</pubDate>
		<dc:creator>raja</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[line numbers]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://rajaseelan.com/?p=140</guid>
		<description><![CDATA[A common question asked by linux beginners, so here&#8217;s how to do it.
Let&#8217;s say you need to search your /etc/passwd file for the users apache AND ftp. You could do it this way:-
Or being a sysadmin, you&#8217;d want to do it smarter.
Use the pipe symbol and the &#8216;-E&#8217; switch with grep will solve this problem.


$ [...]]]></description>
			<content:encoded><![CDATA[<p>A common question asked by linux beginners, so here&#8217;s how to do it.</p>
<p>Let&#8217;s say you need to search your <code>/etc/passwd</code> file for the users <code>apache</code> AND <code>ftp</code>. You could do it this way:-</p>
<div id="attachment_141" class="wp-caption aligncenter" style="width: 526px"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/grep-01-manual.png" alt="The manual way of greppin&#039;" title="grep-01-manual" width="516" height="371" class="size-full wp-image-141" />
<p class="wp-caption-text">The manual way of greppin&#8217;</p>
</div>
<p>Or being a sysadmin, you&#8217;d want to do it smarter.</p>
<p>Use the pipe symbol and the &#8216;-E&#8217; switch with grep will solve this problem.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">$ grep -E 'apache|ftp' /etc/passwd</pre>
</div>
</div>
<div id="attachment_142" class="wp-caption aligncenter" style="width: 526px"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/grep-02-with-e.png" alt="Grepping 2 words at a time" title="grep-02-with-e" width="516" height="371" class="size-full wp-image-142" />
<p class="wp-caption-text">Grepping 2 words at a time</p>
</div>
<p>While your there, lets add some colour to your output. This will help you see where exactly the pattern matches.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">$ grep -E --colour 'apache|ftp' /etc/passwd</pre>
</div>
</div>
<div id="attachment_143" class="wp-caption aligncenter" style="width: 526px"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/grep-03-with-colour.png" alt="Grepping with some colour" title="grep-03-with-colour" width="516" height="371" class="size-full wp-image-143" />
<p class="wp-caption-text">Grepping with some colour</p>
</div>
<p>A final tip that will come in handy, especially when you&#8217;re grepping long config files is the line number. Adding a &#8216;-n&#8217; to your grep will display the line number for the matching term. Notice how adding the &#8216;&#8211;colour&#8217; option makes the line numbers coloured in green, while the actual matched word is coloured in red.</p>
<div class="wp_syntax">
<div class="code">
<pre class="text" style="font-family:monospace;">$ grep -En --colour 'apache|ftp' /etc/passwd</pre>
</div>
</div>
<div id="attachment_144" class="wp-caption aligncenter" style="width: 526px"><img src="http://rajaseelan.com/wp-content/uploads/2009/07/grep-04-colour-line-numbers.png" alt="Grepping, now with colours and line numbers" title="grep-04-colour-line-numbers" width="516" height="371" class="size-full wp-image-144" />
<p class="wp-caption-text">Grepping, now with colours and line numbers</p>
</div>
<p>Till another post, happy <del datetime="2009-07-03T18:12:04+00:00">searching</del> grepping.</p>
]]></content:encoded>
			<wfw:commentRss>http://rajaseelan.com/2009/07/04/how-to-search-grep-for-more-than-one-word-at-a-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
