<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160639#M61207</link>
    <description>That would add a new line to the stream, this would append a string to the line that matches in the stream:&lt;BR /&gt;&lt;BR /&gt;sed -e "/second line of text/ s/.*/&amp;amp; New string added here/" test&lt;BR /&gt;&lt;BR /&gt;Regards,</description>
    <pubDate>Mon, 09 Mar 2009 17:11:30 GMT</pubDate>
    <dc:creator>Ciro  Iriarte</dc:creator>
    <dc:date>2009-03-09T17:11:30Z</dc:date>
    <item>
      <title>script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160636#M61204</link>
      <description>Is there a way to append a new string to a line which is in the middle of a file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For eg: below is my file&lt;BR /&gt;first line of text&lt;BR /&gt;second line of text&lt;BR /&gt;third line of text&lt;BR /&gt;fourth line of text&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i want a output like this:&lt;BR /&gt;first line of text&lt;BR /&gt;second line of text New string added here&lt;BR /&gt;third line of text&lt;BR /&gt;fourth line of text&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Mar 2009 08:02:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160636#M61204</guid>
      <dc:creator>Chapaya</dc:creator>
      <dc:date>2009-03-03T08:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160637#M61205</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;One way is doing like this.&lt;BR /&gt;# sed -e "/second line/ a\test" temp&lt;BR /&gt;first line of text&lt;BR /&gt;second line of text&lt;BR /&gt;test&lt;BR /&gt;third line of text&lt;BR /&gt;fourth line of text&lt;BR /&gt;&lt;BR /&gt;Another if you know specific row number.&lt;BR /&gt;# sed -e "2 a\test" temp&lt;BR /&gt;first line of text&lt;BR /&gt;second line of text&lt;BR /&gt;test&lt;BR /&gt;third line of text&lt;BR /&gt;fourth line of text&lt;BR /&gt;&lt;BR /&gt;The above version is just search and add, make sure (if you're going to use that) that you have a exact match.&lt;BR /&gt;&lt;BR /&gt;Otherwise you can end up like this:&lt;BR /&gt;# sed -e "/text/ a\test" temp&lt;BR /&gt;first line of text&lt;BR /&gt;test&lt;BR /&gt;second line of text&lt;BR /&gt;test&lt;BR /&gt;third line of text&lt;BR /&gt;test&lt;BR /&gt;fourth line of text&lt;BR /&gt;test&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Mar 2009 10:05:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160637#M61205</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-03-03T10:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160638#M61206</link>
      <description>assuming your text is in myfile.  This command will append "new string" including a new line character to end of line that matches "third line of text" and then redirect the result to "newfile"&lt;BR /&gt;&lt;BR /&gt;perl -ne 'if ($_ =~ /^third line of text/i) {$_ =~ s/[\r\n]+//; $_ .= " new string\n";} print "$_";' myfile &amp;gt; newfile</description>
      <pubDate>Mon, 09 Mar 2009 17:05:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160638#M61206</guid>
      <dc:creator>Wilfred Chau_1</dc:creator>
      <dc:date>2009-03-09T17:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160639#M61207</link>
      <description>That would add a new line to the stream, this would append a string to the line that matches in the stream:&lt;BR /&gt;&lt;BR /&gt;sed -e "/second line of text/ s/.*/&amp;amp; New string added here/" test&lt;BR /&gt;&lt;BR /&gt;Regards,</description>
      <pubDate>Mon, 09 Mar 2009 17:11:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160639#M61207</guid>
      <dc:creator>Ciro  Iriarte</dc:creator>
      <dc:date>2009-03-09T17:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160640#M61208</link>
      <description>thanks all.</description>
      <pubDate>Tue, 10 Mar 2009 06:21:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script/m-p/5160640#M61208</guid>
      <dc:creator>Chapaya</dc:creator>
      <dc:date>2009-03-10T06:21:20Z</dc:date>
    </item>
  </channel>
</rss>

