<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Unix Sed Tutorial: Advanced Sed Substitution Examples</title>
	<atom:link href="http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/</link>
	<description>Guides, HowTos and Tips for Technology Geeks</description>
	<lastBuildDate>Thu, 09 Feb 2012 13:04:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: siva</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-140093</link>
		<dc:creator>siva</dc:creator>
		<pubDate>Mon, 14 Nov 2011 06:59:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-140093</guid>
		<description>I am not clear about .can you explain this Grouping and Back-references in Sed.



Thanks in advance.</description>
		<content:encoded><![CDATA[<p>I am not clear about .can you explain this Grouping and Back-references in Sed.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-71464</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 01 Dec 2010 13:32:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-71464</guid>
		<description>Can you please explain this Substitution.
sed -r ‘s/(^&#124;[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g’ numbers.txt

Thanks,
Rafi</description>
		<content:encoded><![CDATA[<p>Can you please explain this Substitution.<br />
sed -r ‘s/(^|[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g’ numbers.txt</p>
<p>Thanks,<br />
Rafi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Logan</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-58497</link>
		<dc:creator>Logan</dc:creator>
		<pubDate>Tue, 10 Aug 2010 22:35:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-58497</guid>
		<description>A complete example of commify (add comma as thousands separator) 

$ cat numbers.txt 
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
1234567890.1234
+1234567890.1234
-1234567890.1234

With the &quot;-r&quot; option, there is no need to escape the paraenthesis and curly brackets.

The simple code below doesn&#039;t work for numeric strings larger that 6.

$ sed -r &#039;s/(^&#124;[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g&#039; numbers.txt
1
12
123
1,234
12,345
123,456
1234,567
12345,678
123456,789
1234567,890
1234567,890.1234
+1234567,890.1234
-1234567,890.1234

This one works. (taken from question 4.14 of http://sed.sourceforge.net/sedfaq.html)
$ sed -r &#039;:a;s/(^&#124;[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g;ta&#039; numbers.txt
1
12
123
1,234
12,345
123,456
1,234,567
12,345,678
123,456,789
1,234,567,890
1,234,567,890.1234
+1,234,567,890.1234
-1,234,567,890.1234</description>
		<content:encoded><![CDATA[<p>A complete example of commify (add comma as thousands separator) </p>
<p>$ cat numbers.txt<br />
1<br />
12<br />
123<br />
1234<br />
12345<br />
123456<br />
1234567<br />
12345678<br />
123456789<br />
1234567890<br />
1234567890.1234<br />
+1234567890.1234<br />
-1234567890.1234</p>
<p>With the &#8220;-r&#8221; option, there is no need to escape the paraenthesis and curly brackets.</p>
<p>The simple code below doesn&#8217;t work for numeric strings larger that 6.</p>
<p>$ sed -r &#8216;s/(^|[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g&#8217; numbers.txt<br />
1<br />
12<br />
123<br />
1,234<br />
12,345<br />
123,456<br />
1234,567<br />
12345,678<br />
123456,789<br />
1234567,890<br />
1234567,890.1234<br />
+1234567,890.1234<br />
-1234567,890.1234</p>
<p>This one works. (taken from question 4.14 of <a href="http://sed.sourceforge.net/sedfaq.html" rel="nofollow">http://sed.sourceforge.net/sedfaq.html</a>)<br />
$ sed -r &#8216;:a;s/(^|[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g;ta&#8217; numbers.txt<br />
1<br />
12<br />
123<br />
1,234<br />
12,345<br />
123,456<br />
1,234,567<br />
12,345,678<br />
123,456,789<br />
1,234,567,890<br />
1,234,567,890.1234<br />
+1,234,567,890.1234<br />
-1,234,567,890.1234</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anjum</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-42343</link>
		<dc:creator>Anjum</dc:creator>
		<pubDate>Fri, 09 Apr 2010 22:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-42343</guid>
		<description>Example 4 reworked and tested on Solaris 9:

echo &quot;Welcome To The Geek Stuff&quot; &#124; sed &#039;s/\&lt;\([A-Z]\)/\(\1\)/g&#039;

Thanks,
-Anjum.</description>
		<content:encoded><![CDATA[<p>Example 4 reworked and tested on Solaris 9:</p>
<p>echo &#8220;Welcome To The Geek Stuff&#8221; | sed &#8216;s/\&lt;\([A-Z]\)/\(\1\)/g&#039;</p>
<p>Thanks,<br />
-Anjum.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anjum</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-42319</link>
		<dc:creator>Anjum</dc:creator>
		<pubDate>Fri, 09 Apr 2010 17:17:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-42319</guid>
		<description>Example 5 may only work on Linux (I don&#039;t see how) but does not work for other systems. The following snippet does work on Sun OS and am sure will work on most systems out there; including Linux:

echo &#039;1234
12121
3434
123&#039; &#124; sed &#039;s/\([0-9]\{3\}\)$/,\1/g;s/^,//&#039;

Thanks,
-Anjum.</description>
		<content:encoded><![CDATA[<p>Example 5 may only work on Linux (I don&#8217;t see how) but does not work for other systems. The following snippet does work on Sun OS and am sure will work on most systems out there; including Linux:</p>
<p>echo &#8217;1234<br />
12121<br />
3434<br />
123&#8242; | sed &#8216;s/\([0-9]\{3\}\)$/,\1/g;s/^,//&#8217;</p>
<p>Thanks,<br />
-Anjum.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guru Prasad</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-36814</link>
		<dc:creator>Guru Prasad</dc:creator>
		<pubDate>Sat, 27 Feb 2010 07:40:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-36814</guid>
		<description>Also, same is the case with example 5 as well...please let me know why</description>
		<content:encoded><![CDATA[<p>Also, same is the case with example 5 as well&#8230;please let me know why</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guru Prasad</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-36813</link>
		<dc:creator>Guru Prasad</dc:creator>
		<pubDate>Sat, 27 Feb 2010 07:37:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-36813</guid>
		<description>Hi,
  Regarding the example 4, when i try it in Red Hat linux, it works, but when i try in HP-UX or SunOS it does not.  Any reason why so?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
  Regarding the example 4, when i try it in Red Hat linux, it works, but when i try in HP-UX or SunOS it does not.  Any reason why so?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Advanced Sed Substitution Examples - Amit Agarwal</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-22622</link>
		<dc:creator>Advanced Sed Substitution Examples - Amit Agarwal</dc:creator>
		<pubDate>Tue, 17 Nov 2009 03:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-22622</guid>
		<description>[...] Read More: Unix Sed Tutorial: Advanced Sed Substitution Examples [...]</description>
		<content:encoded><![CDATA[<p>[...] Read More: Unix Sed Tutorial: Advanced Sed Substitution Examples [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berry</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-21756</link>
		<dc:creator>Berry</dc:creator>
		<pubDate>Sat, 07 Nov 2009 07:41:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-21756</guid>
		<description>@Sasikala,

Following your tips, I found that / plus &quot;smaller than&quot;  can match the left boundary and / plus &quot;larger than&quot; can match the right. Thank you again!</description>
		<content:encoded><![CDATA[<p>@Sasikala,</p>
<p>Following your tips, I found that / plus &#8220;smaller than&#8221;  can match the left boundary and / plus &#8220;larger than&#8221; can match the right. Thank you again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berry</title>
		<link>http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/comment-page-1/#comment-21755</link>
		<dc:creator>Berry</dc:creator>
		<pubDate>Sat, 07 Nov 2009 07:38:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2335#comment-21755</guid>
		<description>@Sasikala,

Oh, I got it. Thank you very much. ^_^

Following your tips, I found that / can match the right. Thank you again!</description>
		<content:encoded><![CDATA[<p>@Sasikala,</p>
<p>Oh, I got it. Thank you very much. ^_^</p>
<p>Following your tips, I found that / can match the right. Thank you again!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Content Delivery Network via Amazon Web Services: CloudFront: static.thegeekstuff.com

Served from: www.thegeekstuff.com @ 2012-02-09 13:34:28 -->
