<?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: Sed Find and Display Text Between Two Strings or Words</title> <atom:link href="http://www.cyberciti.biz/faq/sed-display-text/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/sed-display-text/</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: Moyente</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-66743</link> <dc:creator>Moyente</dc:creator> <pubDate>Thu, 12 Jan 2012 21:48:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-66743</guid> <description>in the same concept, how can i extract all the substring starting with &lt;ds:include and ending with .xml from a long textual string?
example input (remember, the input content is in one line):
10120
expected output:
ds:include ds:uri=&quot;$HOME/lookup/lookup_table.xml
ds:include ds:uri=&quot;$HOME/trans/transform.xml
Thanks
Moyente</description> <content:encoded><![CDATA[<p>in the same concept, how can i extract all the substring starting with &lt;ds:include and ending with .xml from a long textual string?<br
/> example input (remember, the input content is in one line):<br
/> 10120</p><p>expected output:<br
/> ds:include ds:uri=&#8221;$HOME/lookup/lookup_table.xml<br
/> ds:include ds:uri=&#8221;$HOME/trans/transform.xml</p><p>Thanks</p><p>Moyente</p> ]]></content:encoded> </item> <item><title>By: j0hny</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-65478</link> <dc:creator>j0hny</dc:creator> <pubDate>Sat, 10 Dec 2011 21:10:53 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-65478</guid> <description>sorry, should be: sed  &#124; tr -d &#039; &#039; &#124; tr -d &#039;\n&#039; &#124; tr -d &#039;\t&#039;</description> <content:encoded><![CDATA[<p>sorry, should be: sed  | tr -d &#8216; &#8216; | tr -d &#8216;\n&#8217; | tr -d &#8216;\t&#8217;</p> ]]></content:encoded> </item> <item><title>By: j0hny</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-65477</link> <dc:creator>j0hny</dc:creator> <pubDate>Sat, 10 Dec 2011 21:06:36 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-65477</guid> <description>when using sed try to add some tr commands... eg. sed  &#124; tr -d&#039; &#039; &#124; tr -d&#039;\n&#039; &#124; tr -d&#039;\t&#039;
this will delete all spaces, newlines etc that sed might add to your string
to check the spacing you can try: cat file.txt &#124; od -c (find the delimiter), use sed as regulary (when it fails), cat new_by_sed_created_file.txt &#124; od -c (check the changes)</description> <content:encoded><![CDATA[<p>when using sed try to add some tr commands&#8230; eg. sed  | tr -d&#8217; &#8216; | tr -d&#8217;\n&#8217; | tr -d&#8217;\t&#8217;</p><p>this will delete all spaces, newlines etc that sed might add to your string</p><p>to check the spacing you can try: cat file.txt | od -c (find the delimiter), use sed as regulary (when it fails), cat new_by_sed_created_file.txt | od -c (check the changes)</p> ]]></content:encoded> </item> <item><title>By: bhavya</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-65207</link> <dc:creator>bhavya</dc:creator> <pubDate>Mon, 05 Dec 2011 20:07:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-65207</guid> <description>Hi ,
There are some problems I am facing with linux right now.
This is what I am doing to generate a cryptographic signature fron bash script....
step1. I encrypt a text : encrypt(bhavyakailkhurabhavyakailkhura) and get a encrypted string sdfghjklsdfghjklzxcvbnmghjkdfghjkzxcvbnmzxc.
step2. I copy that string manually from mouse no commands used and append it with a file..
$ cat textfile.txt...
user=bhavya
signature={sdfghjklsdfghjklzxcvbnmghjkdfghjkzxcvbnmzxc}
step3. Using &quot;sed&quot; on text file I send text between &quot;{&quot; and &quot;}&quot; to another file bhavya.txt
step4. now when I try to decrypt bhavya.txt it say error in reading file. I checked the text is same as encrypted. When I copy original encrypted text in step 1 and decrypt It works.
I think the problem is sed command changes spacing between text its not same as copying using mouse. Do you have any idea how we can solve this problem?
Sorry for clumsy and lengthy explanation.
Thanks</description> <content:encoded><![CDATA[<p>Hi ,<br
/> There are some problems I am facing with linux right now.</p><p>This is what I am doing to generate a cryptographic signature fron bash script&#8230;.</p><p>step1. I encrypt a text : encrypt(bhavyakailkhurabhavyakailkhura) and get a encrypted string sdfghjklsdfghjklzxcvbnmghjkdfghjkzxcvbnmzxc.<br
/> step2. I copy that string manually from mouse no commands used and append it with a file..</p><p>$ cat textfile.txt&#8230;<br
/> user=bhavya<br
/> signature={sdfghjklsdfghjklzxcvbnmghjkdfghjkzxcvbnmzxc}</p><p>step3. Using &#8220;sed&#8221; on text file I send text between &#8220;{&#8221; and &#8220;}&#8221; to another file bhavya.txt<br
/> step4. now when I try to decrypt bhavya.txt it say error in reading file. I checked the text is same as encrypted. When I copy original encrypted text in step 1 and decrypt It works.</p><p>I think the problem is sed command changes spacing between text its not same as copying using mouse. Do you have any idea how we can solve this problem?</p><p>Sorry for clumsy and lengthy explanation.</p><p>Thanks</p> ]]></content:encoded> </item> <item><title>By: saravana</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-62933</link> <dc:creator>saravana</dc:creator> <pubDate>Thu, 29 Sep 2011 04:37:04 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-62933</guid> <description>Hi,
I need to modify /etc/filesystems file in IBM AIX ,where i have to search for a existing FS stanza (eg /opt) then after that stanza i had to put my new FS stanza.
/dev/optlv:
dev = /dev/optlv
Vfs - jfs2
mount = yes
/new/lv                      #newly insered line
dev = /new/lv      #newly inserted line
Vfs = jfs2           #newly inserted line
/tmp
dev = /dev/tmplv
............................</description> <content:encoded><![CDATA[<p>Hi,</p><p> I need to modify /etc/filesystems file in IBM AIX ,where i have to search for a existing FS stanza (eg /opt) then after that stanza i had to put my new FS stanza.</p><p>/dev/optlv:<br
/> dev = /dev/optlv<br
/> Vfs &#8211; jfs2<br
/> mount = yes</p><p>/new/lv                      #newly insered line<br
/> dev = /new/lv      #newly inserted line<br
/> Vfs = jfs2           #newly inserted line</p><p>/tmp<br
/> dev = /dev/tmplv<br
/> &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</p> ]]></content:encoded> </item> <item><title>By: Swaroop</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-60637</link> <dc:creator>Swaroop</dc:creator> <pubDate>Mon, 11 Jul 2011 06:53:30 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-60637</guid> <description>I have found a problem. I need to extract the text between two strings and replace the characters with some symbol.
Ex : initially.. ABC ghr fhufhuw XYZ
Output :ABC !!!!!!!!!!!!!!! XYZ.
Can you please , help me out.I need to fix this.</description> <content:encoded><![CDATA[<p>I have found a problem. I need to extract the text between two strings and replace the characters with some symbol.</p><p>Ex : initially.. ABC ghr fhufhuw XYZ<br
/> Output :ABC !!!!!!!!!!!!!!! XYZ.<br
/> Can you please , help me out.I need to fix this.</p> ]]></content:encoded> </item> <item><title>By: John</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-59499</link> <dc:creator>John</dc:creator> <pubDate>Wed, 18 May 2011 20:41:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-59499</guid> <description>For some reason none of listed example does not working properly when trying to search for ,no matter which command is applied it always show rest of content in file.Could be because second word in search is  and that causing problem for some reason.But i managed to make it work by this command:
sed -n &#039;s//&amp;/p&#039; index.html
It shows entire line where is located,but that is not problem,since the key was to find out content between and  tag.</description> <content:encoded><![CDATA[<p>For some reason none of listed example does not working properly when trying to search for ,no matter which command is applied it always show rest of content in file.Could be because second word in search is  and that causing problem for some reason.But i managed to make it work by this command:<br
/> sed -n &#8216;s//&amp;/p&#8217; index.html<br
/> It shows entire line where is located,but that is not problem,since the key was to find out content between and  tag.</p> ]]></content:encoded> </item> <item><title>By: Radheshyam</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-59314</link> <dc:creator>Radheshyam</dc:creator> <pubDate>Mon, 09 May 2011 02:15:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-59314</guid> <description>Hi,
I found a similar command. Here the strings at both ends (FOO and BAR) will be ignored.
&lt;pre&gt;sed -e &quot;s/.*FOO//;s/BAR.*//&quot; test.txt&lt;pre&gt;
For example:
&lt;pre&gt;echo &quot;Test to find string between words FOO-/*+_and_+*/- BAR&quot; &#124; sed -e &quot;s/.*FOO//;s/BAR.*//&quot;&lt;pre&gt;</description> <content:encoded><![CDATA[<p>Hi,</p><p>I found a similar command. Here the strings at both ends (FOO and BAR) will be ignored.</p><pre>sed -e "s/.*FOO//;s/BAR.*//" test.txt</pre><pre>
For example:
</pre><pre>echo "Test to find string between words FOO-/*+_and_+*/- BAR" | sed -e "s/.*FOO//;s/BAR.*//"</pre><pre></pre>]]></content:encoded> </item> <item><title>By: Alex</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-48266</link> <dc:creator>Alex</dc:creator> <pubDate>Wed, 07 Jul 2010 11:27:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-48266</guid> <description>Hello,
What if I have a txt like this:
Begin
yyyy
yyyy
End
.......
Begin
xxxx
xxxx
End
what if I want to display the text between &quot;begin&quot; and &quot;end&quot; but only for the first sequence, or only for the 2nd or 3rd?
Thanks a lot.</description> <content:encoded><![CDATA[<p>Hello,<br
/> What if I have a txt like this:<br
/> Begin<br
/> yyyy<br
/> yyyy<br
/> End<br
/> &#8230;&#8230;.<br
/> Begin<br
/> xxxx<br
/> xxxx<br
/> End</p><p>what if I want to display the text between &#8220;begin&#8221; and &#8220;end&#8221; but only for the first sequence, or only for the 2nd or 3rd?<br
/> Thanks a lot.</p> ]]></content:encoded> </item> <item><title>By: AVKLINUX</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-48048</link> <dc:creator>AVKLINUX</dc:creator> <pubDate>Thu, 24 Jun 2010 23:38:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-48048</guid> <description>what if I only want to match 2 strings for 1st instance . ?
not globally.
THANKS
AVK</description> <content:encoded><![CDATA[<p>what if I only want to match 2 strings for 1st instance . ?</p><p>not globally.</p><p>THANKS<br
/> AVK</p> ]]></content:encoded> </item> <item><title>By: Rajiv</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-45459</link> <dc:creator>Rajiv</dc:creator> <pubDate>Thu, 07 Jan 2010 05:21:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-45459</guid> <description>I have scenario where i need to copy all the lines in a logfile between 2 specific time intervals. say 5 PM to 6 PM, as the file is quite huge in size we are unable to open the file. please suggest a work around .
Thanks
Rajiv.</description> <content:encoded><![CDATA[<p>I have scenario where i need to copy all the lines in a logfile between 2 specific time intervals. say 5 PM to 6 PM, as the file is quite huge in size we are unable to open the file. please suggest a work around .</p><p>Thanks<br
/> Rajiv.</p> ]]></content:encoded> </item> <item><title>By: dinu</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-43291</link> <dc:creator>dinu</dc:creator> <pubDate>Fri, 21 Aug 2009 10:10:47 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-43291</guid> <description>Shell script to print contents of file from given line number to next given number of lines</description> <content:encoded><![CDATA[<p>Shell script to print contents of file from given line number to next given number of lines</p> ]]></content:encoded> </item> <item><title>By: Robsteranium</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-42097</link> <dc:creator>Robsteranium</dc:creator> <pubDate>Wed, 17 Jun 2009 14:18:25 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-42097</guid> <description>You may find that a web scraper using xpath is more appropriate for extracting data from web pages.  Try ScRubyt!</description> <content:encoded><![CDATA[<p>You may find that a web scraper using xpath is more appropriate for extracting data from web pages.  Try ScRubyt!</p> ]]></content:encoded> </item> <item><title>By: Nico Maas</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-42089</link> <dc:creator>Nico Maas</dc:creator> <pubDate>Wed, 17 Jun 2009 07:24:49 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-42089</guid> <description>I meant this Code:
a href=&quot;../messages/index.php&quot;  class=&quot;navilink&quot;&gt;&lt;b&gt;1 neue Nachricht&lt;/b&gt; </description> <content:encoded><![CDATA[<p>I meant this Code:</p><p>a href=&#8221;../messages/index.php&#8221;  class=&#8221;navilink&#8221;&gt;<b>1 neue Nachricht</b></p> ]]></content:encoded> </item> <item><title>By: Nico Maas</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-42087</link> <dc:creator>Nico Maas</dc:creator> <pubDate>Wed, 17 Jun 2009 07:21:33 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-42087</guid> <description>Hi there,
I got some problem.
I got this html Code:
&lt;code&gt;
&lt;a href=&quot;../messages/index.php&quot; rel=&quot;nofollow&quot;&gt;&lt;b&gt;1 neue Nachricht&lt;/b&gt;
&lt;/code&gt;
And need to extract the Text &quot;1 neue Nachricht&quot; - but that thing can change.
Any way in doing this by sed?
Thanks</description> <content:encoded><![CDATA[<p>Hi there,<br
/> I got some problem.<br
/> I got this html Code:</p><p> <code></p><p><a
href="../messages/index.php" rel="nofollow"><b>1 neue Nachricht</b></p><p> </a></code></p><p>And need to extract the Text &#8220;1 neue Nachricht&#8221; &#8211; but that thing can change.<br
/> Any way in doing this by sed?</p><p>Thanks</p> ]]></content:encoded> </item> <item><title>By: sedbeginner</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-41611</link> <dc:creator>sedbeginner</dc:creator> <pubDate>Thu, 14 May 2009 23:25:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-41611</guid> <description>I have a similar problem, I have a long line of text and within this line I have my start and end variable and I need the text between start and end.
Example:
t6gd68g d9d8j5%9j30j 0jf087*(&amp;&amp;^*2hd920STARTid8 =e72920 2d9nf9END93nf300j90
needed output between START and END, resulting in id8 =e72920 2d9nf9
Any Idea how to do this?
Cheers.</description> <content:encoded><![CDATA[<p>I have a similar problem, I have a long line of text and within this line I have my start and end variable and I need the text between start and end.</p><p>Example:</p><p>t6gd68g d9d8j5%9j30j 0jf087*(&amp;&amp;^*2hd920STARTid8 =e72920 2d9nf9END93nf300j90</p><p>needed output between START and END, resulting in id8 =e72920 2d9nf9</p><p>Any Idea how to do this?</p><p>Cheers.</p> ]]></content:encoded> </item> <item><title>By: codegazer</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-41423</link> <dc:creator>codegazer</dc:creator> <pubDate>Fri, 01 May 2009 00:48:17 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-41423</guid> <description>Hi,
Have been reading your blogs for quite some time now and are very informative.
On this particular script, I need some advice. Say I have 2 words, Begin and End that I am looking for in a file. For Ex.
Begin
line1
line2
End
I am trying to modify your script. I want to delete what lies between these 2 patterns viz. Begin/End but I need to keep the words Begin and End. I end up deleting those as well.
Any inputs ?
Thanks</description> <content:encoded><![CDATA[<p>Hi,<br
/> Have been reading your blogs for quite some time now and are very informative.<br
/> On this particular script, I need some advice. Say I have 2 words, Begin and End that I am looking for in a file. For Ex.</p><p>Begin<br
/> line1<br
/> line2<br
/> End</p><p>I am trying to modify your script. I want to delete what lies between these 2 patterns viz. Begin/End but I need to keep the words Begin and End. I end up deleting those as well.</p><p>Any inputs ?</p><p>Thanks</p> ]]></content:encoded> </item> <item><title>By: reza</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-38744</link> <dc:creator>reza</dc:creator> <pubDate>Wed, 10 Sep 2008 23:58:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-38744</guid> <description>hi
i have a file like this:
...
ther: Part II (1974) .... Vito Corleone
... aka Mario Puzo&#039;s The Godfather: Part II (USA: complete title)
# Mean Streets (1973) .... Johnny Boy
# Bang the Drum Slowly (1973) .... Bruce Pearson
# The Gang That
...
I need to delete all between &#039;)&#039; and the &#039;#&#039; (keep the # start of each line as is)
output:
...
ther: Part II (1974)
# Mean Streets (1973)
# Bang the Drum Slowly (1973)
# The Gang That
....
how do i do it?</description> <content:encoded><![CDATA[<p>hi<br
/> i have a file like this:<br
/> &#8230;<br
/> ther: Part II (1974) &#8230;. Vito Corleone<br
/> &#8230; aka Mario Puzo&#8217;s The Godfather: Part II (USA: complete title)<br
/> # Mean Streets (1973) &#8230;. Johnny Boy<br
/> # Bang the Drum Slowly (1973) &#8230;. Bruce Pearson<br
/> # The Gang That<br
/> &#8230;<br
/> I need to delete all between &#8216;)&#8217; and the &#8216;#&#8217; (keep the # start of each line as is)<br
/> output:<br
/> &#8230;<br
/> ther: Part II (1974)<br
/> # Mean Streets (1973)<br
/> # Bang the Drum Slowly (1973)<br
/> # The Gang That<br
/> &#8230;.</p><p>how do i do it?</p> ]]></content:encoded> </item> <item><title>By: yoander</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-38083</link> <dc:creator>yoander</dc:creator> <pubDate>Wed, 11 Jun 2008 16:29:53 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-38083</guid> <description>Very useful tip about sed</description> <content:encoded><![CDATA[<p>Very useful tip about sed</p> ]]></content:encoded> </item> <item><title>By: Robsteranium</title><link>http://www.cyberciti.biz/faq/sed-display-text/#comment-38042</link> <dc:creator>Robsteranium</dc:creator> <pubDate>Thu, 05 Jun 2008 15:23:22 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=1015#comment-38042</guid> <description>&lt;blockquote cite=&quot;I want to print only the substring between two words/strings and not those two words/strings&quot;&gt;
I arrived here struggling with this one but I&#039;ve just figured it out!
/WORD1/,/WORD2/{
/WORD1/d
/WORD2/d
p
}
hth</description> <content:encoded><![CDATA[<blockquote
cite="I want to print only the substring between two words/strings and not those two words/strings"><p>I arrived here struggling with this one but I&#8217;ve just figured it out!</p><p>/WORD1/,/WORD2/{<br
/> /WORD1/d<br
/> /WORD2/d<br
/> p<br
/> }</p><p>hth</p></blockquote> ]]></content:encoded> </item> </channel> </rss>
