<?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: Multi-Line File Operation with 6 Practical Examples</title>
	<atom:link href="http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-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: Greg</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-163403</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Tue, 27 Dec 2011 23:45:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-163403</guid>
		<description>I got example #6 working in a windows batch file as a multi-line find/replace. Many other sed multi-line examples I found online just didn&#039;t work in all cases. But a modified example #6 like the following works: 

sed --text -n -e &quot;s&#124;2011&#124;&amp;&#124;p&quot; -e &quot;$^!N;/Directory.*\n.*2011/P; D&quot; input.txt &gt; output.txt

This sed line, running under the windows ver. of sed, finds either lines with &quot;2011&quot; or lines with &quot;Directory&quot; only if &quot;2011&quot; is on the next line, and the output is redirected to a separate file. The --text option helps generate the proper CR/LF for windows. Also, the exclamation char has to be &quot;escaped&quot; in a batch file *IF* enabledelayedexpansion is being used in context.</description>
		<content:encoded><![CDATA[<p>I got example #6 working in a windows batch file as a multi-line find/replace. Many other sed multi-line examples I found online just didn&#8217;t work in all cases. But a modified example #6 like the following works: </p>
<p>sed &#8211;text -n -e &#8220;s|2011|&amp;|p&#8221; -e &#8220;$^!N;/Directory.*\n.*2011/P; D&#8221; input.txt &gt; output.txt</p>
<p>This sed line, running under the windows ver. of sed, finds either lines with &#8220;2011&#8243; or lines with &#8220;Directory&#8221; only if &#8220;2011&#8243; is on the next line, and the output is redirected to a separate file. The &#8211;text option helps generate the proper CR/LF for windows. Also, the exclamation char has to be &#8220;escaped&#8221; in a batch file *IF* enabledelayedexpansion is being used in context.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: frankhuang</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-70144</link>
		<dc:creator>frankhuang</dc:creator>
		<pubDate>Thu, 18 Nov 2010 01:58:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-70144</guid>
		<description>example 5 works because the last line is empty line, and
 sed -n &#039;$!h;$H;$x;$p&#039; thegeekstuff.txt
also works to Print Last 2 Lines of a file</description>
		<content:encoded><![CDATA[<p>example 5 works because the last line is empty line, and<br />
 sed -n &#8216;$!h;$H;$x;$p&#8217; thegeekstuff.txt<br />
also works to Print Last 2 Lines of a file</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Indraneel Nag</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-64144</link>
		<dc:creator>Indraneel Nag</dc:creator>
		<pubDate>Thu, 23 Sep 2010 10:45:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-64144</guid>
		<description>How can you make multiline text file to one single line text file</description>
		<content:encoded><![CDATA[<p>How can you make multiline text file to one single line text file</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Masood</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-30930</link>
		<dc:creator>Masood</dc:creator>
		<pubDate>Mon, 25 Jan 2010 23:31:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-30930</guid>
		<description>In Example 5,the output is only last line and not last two lines.Can you confirm plz?</description>
		<content:encoded><![CDATA[<p>In Example 5,the output is only last line and not last two lines.Can you confirm plz?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Masood</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-30927</link>
		<dc:creator>Masood</dc:creator>
		<pubDate>Mon, 25 Jan 2010 23:12:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-30927</guid>
		<description>In Example 4 ,if total number of lines in sample script are even including blank lines then I think we can also use  following sed command
sed &#039;N;$d&#039; thegeekstuff.txt</description>
		<content:encoded><![CDATA[<p>In Example 4 ,if total number of lines in sample script are even including blank lines then I think we can also use  following sed command<br />
sed &#8216;N;$d&#8217; thegeekstuff.txt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unix Sed Tutorial : 7 Examples for Sed Hold and Pattern Buffer Operations</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-25397</link>
		<dc:creator>Unix Sed Tutorial : 7 Examples for Sed Hold and Pattern Buffer Operations</dc:creator>
		<pubDate>Wed, 09 Dec 2009 06:03:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-25397</guid>
		<description>[...] &#8212;  sed printing, sed deletion, sed substitute , sed file write, sed multiple commands, sed multi-line operation, and sed manipulate file [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8212;  sed printing, sed deletion, sed substitute , sed file write, sed multiple commands, sed multi-line operation, and sed manipulate file [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Destillat KW48-2009 &#124; duetsch.info - GNU/Linux, Open Source, Softwareentwicklung, Selbstmanagement, Vim ...</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-23805</link>
		<dc:creator>Destillat KW48-2009 &#124; duetsch.info - GNU/Linux, Open Source, Softwareentwicklung, Selbstmanagement, Vim ...</dc:creator>
		<pubDate>Fri, 27 Nov 2009 09:37:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-23805</guid>
		<description>[...] Unix Sed Tutorial: Multi-Line File Operation with 6 Practical Examples [...]</description>
		<content:encoded><![CDATA[<p>[...] Unix Sed Tutorial: Multi-Line File Operation with 6 Practical Examples [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sasikala</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-23656</link>
		<dc:creator>Sasikala</dc:creator>
		<pubDate>Thu, 26 Nov 2009 04:28:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-23656</guid>
		<description>Yes Berry, you are absolutely correct.</description>
		<content:encoded><![CDATA[<p>Yes Berry, you are absolutely correct.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berry</title>
		<link>http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/comment-page-1/#comment-23567</link>
		<dc:creator>Berry</dc:creator>
		<pubDate>Wed, 25 Nov 2009 14:41:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=2473#comment-23567</guid>
		<description>In Example 2, I think the command provided in the article only works when the number of consecutive blank lines is even. Because in the left part, sed &#039;/./=&#039; only print the line number before the non-blank line, the blank line is not changed. But in the right part, join every two lines (both non-blank and blank) into one line and substitute the \n with space. Then, if the number of consecutive blank lines in the original file is odd, that the last blank line will join the line number of next line.

For example:
aaa
blank
bbb

After the left part:
1
aaa
blank
3
bbb

So, I think the solution can be found in the left part
sed &#039;/./=&#039; thegeekstuff.txt &#124; sed &#039;/./{
N
s/\n/ /
}&#039;</description>
		<content:encoded><![CDATA[<p>In Example 2, I think the command provided in the article only works when the number of consecutive blank lines is even. Because in the left part, sed &#8216;/./=&#8217; only print the line number before the non-blank line, the blank line is not changed. But in the right part, join every two lines (both non-blank and blank) into one line and substitute the \n with space. Then, if the number of consecutive blank lines in the original file is odd, that the last blank line will join the line number of next line.</p>
<p>For example:<br />
aaa<br />
blank<br />
bbb</p>
<p>After the left part:<br />
1<br />
aaa<br />
blank<br />
3<br />
bbb</p>
<p>So, I think the solution can be found in the left part<br />
sed &#8216;/./=&#8217; thegeekstuff.txt | sed &#8216;/./{<br />
N<br />
s/\n/ /<br />
}&#8217;</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 16:00:02 -->
