<?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 sed new line not working in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300013#M62653</link>
    <description>I want to insert in a file after #test &lt;BR /&gt;2lines line1 line2  sed  's/#test/&amp;amp;\n'line1"\n"line2'/' file&lt;BR /&gt;&lt;BR /&gt;Not working.&lt;BR /&gt;My output:&lt;BR /&gt;#testnline1nline2&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;Sed version is 3.02&lt;BR /&gt;What is wrong ?&lt;BR /&gt;</description>
    <pubDate>Tue, 04 Nov 2008 12:19:17 GMT</pubDate>
    <dc:creator>ionut_lascu</dc:creator>
    <dc:date>2008-11-04T12:19:17Z</dc:date>
    <item>
      <title>sed new line not working</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300013#M62653</link>
      <description>I want to insert in a file after #test &lt;BR /&gt;2lines line1 line2  sed  's/#test/&amp;amp;\n'line1"\n"line2'/' file&lt;BR /&gt;&lt;BR /&gt;Not working.&lt;BR /&gt;My output:&lt;BR /&gt;#testnline1nline2&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;Sed version is 3.02&lt;BR /&gt;What is wrong ?&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Nov 2008 12:19:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300013#M62653</guid>
      <dc:creator>ionut_lascu</dc:creator>
      <dc:date>2008-11-04T12:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: sed new line not working</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300014#M62654</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;sounds wierd that the \n doesn't work... it should work with any version of sed imo.&lt;BR /&gt;&lt;BR /&gt;But, I'm not sure this will work since I don't have anything to test it on :P&lt;BR /&gt;$~&amp;gt; sed "/#test/ a\line1\;a\line2\" file&lt;BR /&gt;&lt;BR /&gt;Otherwise this should also work:&lt;BR /&gt;$~&amp;gt; sed -e "/#test/ a\line1\" -e "/line1/ a\line2\" file&lt;BR /&gt;&lt;BR /&gt;a\ is append after matched line.&lt;BR /&gt;&lt;BR /&gt;Hope this helps you :)&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Tue, 04 Nov 2008 13:04:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300014#M62654</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2008-11-04T13:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: sed new line not working</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300015#M62655</link>
      <description>not working.&lt;BR /&gt;On sed 4.02 works fine.&lt;BR /&gt;sed 's/#test/&amp;amp;\n'line1"\n"line2'/' file &lt;BR /&gt;&lt;BR /&gt;On sed 3.02 \a not working.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Nov 2008 06:49:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300015#M62655</guid>
      <dc:creator>ionut_lascu</dc:creator>
      <dc:date>2008-11-05T06:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: sed new line not working</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300016#M62656</link>
      <description>Too clarify... it's not \a, it's a\.&lt;BR /&gt;The part "/#test/" will search for any occurance of #test. "a\Line1" will append after the matched occurance the trailing characters that is listed after "\".&lt;BR /&gt;&lt;BR /&gt;But as he said, didn't work... I tried it last night and found that \n is probably the only reasonable way unless you do 2 sed's.&lt;BR /&gt;&lt;BR /&gt;$~&amp;gt; sed -i "/#test/ a\Line1" file.txt&lt;BR /&gt;$~&amp;gt; sed -i "/Line1/ a\Line2" file.txt&lt;BR /&gt;&lt;BR /&gt;but since "-i" parameter changes the original file maybe it's better to "-e" and redirect the output to a new file like this&lt;BR /&gt;&lt;BR /&gt;$~&amp;gt; sed -e "/#test/ a\Line1" file.txt &amp;gt; newfile.txt&lt;BR /&gt;$~&amp;gt; sed -i "/Line1/ a\Line2" newfile.txt&lt;BR /&gt;&lt;BR /&gt;But if your version works now with \n, I would say it's simpler too use my method described above.&lt;BR /&gt;&lt;BR /&gt;$~&amp;gt; sed -e "/#test/ a\Line1\nLine2" file.txt&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Thu, 06 Nov 2008 08:30:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300016#M62656</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2008-11-06T08:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: sed new line not working</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300017#M62657</link>
      <description>$~&amp;gt; sed -i "/#test/ a\Line1" file.txt&lt;BR /&gt;sed: invalid option -- i&lt;BR /&gt;&lt;BR /&gt;$~&amp;gt; sed -e "/#test/ a\Line1" file.txt &amp;gt; newfile.txt&lt;BR /&gt;sed: -e expression #1, char 11: Extra characters after command&lt;BR /&gt;&lt;BR /&gt;My version works with \n only on 4.02 version, I need to work on another box with 3.02 sed version&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2008 09:20:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300017#M62657</guid>
      <dc:creator>ionut_lascu</dc:creator>
      <dc:date>2008-11-06T09:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: sed new line not working</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300018#M62658</link>
      <description>I have tried this on a couple of boxes here:&lt;BR /&gt;&lt;BR /&gt;  sed 's/#test/&amp;amp;\^Jline1\^Jline2/' testfile&lt;BR /&gt;&lt;BR /&gt;Where it says ^J, do [CTRL+V][CTRL+J].&lt;BR /&gt;&lt;BR /&gt;David&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2008 16:58:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-new-line-not-working/m-p/4300018#M62658</guid>
      <dc:creator>David C. Brown</dc:creator>
      <dc:date>2008-11-06T16:58:57Z</dc:date>
    </item>
  </channel>
</rss>

