<?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: Delete text or paragraph between two sections using sed</title> <atom:link href="http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: ahmed</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-60512</link> <dc:creator>ahmed</dc:creator> <pubDate>Wed, 06 Jul 2011 12:27:52 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-60512</guid> <description>Great , just what i wanted!!!</description> <content:encoded><![CDATA[<p>Great , just what i wanted!!!</p> ]]></content:encoded> </item> <item><title>By: jaganath</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-55927</link> <dc:creator>jaganath</dc:creator> <pubDate>Wed, 23 Feb 2011 06:46:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-55927</guid> <description>how can i a do electrisity bill in mysql</description> <content:encoded><![CDATA[<p>how can i a do electrisity bill in mysql</p> ]]></content:encoded> </item> <item><title>By: Gnaural</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-43144</link> <dc:creator>Gnaural</dc:creator> <pubDate>Sun, 16 Aug 2009 01:53:27 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-43144</guid> <description>As for people asking Sam&#039;s question (11.27.07), the problem is two fold. One, using sed&#039;s pattern matching with the &quot;d&quot; (delete) clobbers whole lines, as you noted. The solution would seem to to use the &quot;s&quot; (substitute) form instead:
&lt;code&gt; sed &#039;s/WORD1.*WORD2//g&#039; input.txt &lt;/code&gt;
BUT then you discover the larger problem: sed by default does all it&#039;s processing one line at a time (e.g., it fills it&#039;s processing buffer up to each &#039;\n&#039; it  encounters).
The formal approaches include using sed&#039;s &quot;hold space&quot; and &quot;pattern space&quot; commands, N, H/h,G/g,x  as hinted here:
http://www.gnu.org/software/sed/manual/html_node/Other-Commands.html
I used that route in an email formatting script, but these days if i can get away with quick&#039;n&#039;dirty, i try to just strip all occurrences of  &#039;\n&#039; from the stream you give sed like this:
&lt;code&gt;cat input.txt &#124; tr -d &#039;\n&#039; &#124; sed &#039;s/WORD1.*WORD2//g&#039;  &lt;/code&gt;
No files i&#039;ve worked on are big enough to blow sed&#039;s buffer so far.</description> <content:encoded><![CDATA[<p>As for people asking Sam&#8217;s question (11.27.07), the problem is two fold. One, using sed&#8217;s pattern matching with the &#8220;d&#8221; (delete) clobbers whole lines, as you noted. The solution would seem to to use the &#8220;s&#8221; (substitute) form instead:<br
/> <code> sed 's/WORD1.*WORD2//g' input.txt </code><br
/> BUT then you discover the larger problem: sed by default does all it&#8217;s processing one line at a time (e.g., it fills it&#8217;s processing buffer up to each &#8216;\n&#8217; it  encounters).<br
/> The formal approaches include using sed&#8217;s &#8220;hold space&#8221; and &#8220;pattern space&#8221; commands, N, H/h,G/g,x  as hinted here:<br
/> <a
href="http://www.gnu.org/software/sed/manual/html_node/Other-Commands.html" rel="nofollow">http://www.gnu.org/software/sed/manual/html_node/Other-Commands.html</a><br
/> I used that route in an email formatting script, but these days if i can get away with quick&#8217;n'dirty, i try to just strip all occurrences of  &#8216;\n&#8217; from the stream you give sed like this:<br
/> <code>cat input.txt | tr -d '\n' | sed 's/WORD1.*WORD2//g' </code><br
/> No files i&#8217;ve worked on are big enough to blow sed&#8217;s buffer so far.</p> ]]></content:encoded> </item> <item><title>By: Jasan</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-41393</link> <dc:creator>Jasan</dc:creator> <pubDate>Wed, 29 Apr 2009 14:45:14 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-41393</guid> <description>tannu: you can also use &quot;grep -v&quot;</description> <content:encoded><![CDATA[<p>tannu: you can also use &#8220;grep -v&#8221;</p> ]]></content:encoded> </item> <item><title>By: tannu</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-38714</link> <dc:creator>tannu</dc:creator> <pubDate>Sat, 06 Sep 2008 01:06:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-38714</guid> <description>How to delete following line from a xml file.
#vi package.xml
drivers-3.6.1-${release}.${arch}.rpm
..
..
#
I tried  sed -e &#039;/drivers-3.6.1-${release}.${arch}.rpm /d&#039; /root/package.xml &gt; /root/output.txt</description> <content:encoded><![CDATA[<p>How to delete following line from a xml file.<br
/> #vi package.xml<br
/> drivers-3.6.1-${release}.${arch}.rpm<br
/> ..<br
/> ..<br
/> #<br
/> I tried  sed -e &#8216;/drivers-3.6.1-${release}.${arch}.rpm /d&#8217; /root/package.xml &gt; /root/output.txt</p> ]]></content:encoded> </item> <item><title>By: Johan</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-37272</link> <dc:creator>Johan</dc:creator> <pubDate>Tue, 08 Jan 2008 10:22:49 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-37272</guid> <description>How can i make the script to look in subfolders?</description> <content:encoded><![CDATA[<p>How can i make the script to look in subfolders?</p> ]]></content:encoded> </item> <item><title>By: Sam</title><link>http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-37087</link> <dc:creator>Sam</dc:creator> <pubDate>Tue, 27 Nov 2007 09:44:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/#comment-37087</guid> <description>but the command
sed -e &#039;/word1/,/word2/d&#039; deletes the whole line in case the given text is like this :
unix word1 java  word2
if the text between word1 and word2 only is to be deleted then this is not the solution. Can I get some help on this aspect.... thnks in advance</description> <content:encoded><![CDATA[<p>but the command</p><p>sed -e &#8216;/word1/,/word2/d&#8217; deletes the whole line in case the given text is like this :</p><p>unix word1 java  word2</p><p>if the text between word1 and word2 only is to be deleted then this is not the solution. Can I get some help on this aspect&#8230;. thnks in advance</p> ]]></content:encoded> </item> </channel> </rss>
