<?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: sed question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490605#M801220</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Your task can be accomplished easily with perl:&lt;BR /&gt;&lt;BR /&gt;==&lt;BR /&gt;[root@cc0070 /root]# cat infile&lt;BR /&gt;abc&lt;BR /&gt;History&lt;BR /&gt;def&lt;BR /&gt;History abcdef abcdef&lt;BR /&gt;abc&lt;BR /&gt;abc&lt;BR /&gt;a History a b c d e&lt;BR /&gt;b History a b c d e&lt;BR /&gt;[root@cc0070 /root]# ./testperl &lt;BR /&gt;[root@cc0070 /root]# cat outfile&lt;BR /&gt;abc&lt;BR /&gt;History&lt;BR /&gt;INSERTED_TEXT&lt;BR /&gt;def&lt;BR /&gt;History abcdef abcdef&lt;BR /&gt;INSERTED_TEXT&lt;BR /&gt;abc&lt;BR /&gt;abc&lt;BR /&gt;a History a b c d e&lt;BR /&gt;b History a b c d e&lt;BR /&gt;You have new mail in /var/spool/mail/root&lt;BR /&gt;[root@cc0070 /root]# cat testperl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt; &lt;BR /&gt;open (INFILE, "infile");&lt;BR /&gt;open (OUTFILE, "&amp;gt;outfile");&lt;BR /&gt;while (&lt;INFILE&gt;)&lt;BR /&gt;{&lt;BR /&gt;  $_ =~s/^History(.*)/History\1\nINSERTED_TEXT/g;&lt;BR /&gt;  print OUTFILE $_;&lt;BR /&gt;}&lt;BR /&gt;==&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/INFILE&gt;</description>
    <pubDate>Wed, 07 Feb 2001 03:52:38 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2001-02-07T03:52:38Z</dc:date>
    <item>
      <title>sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490604#M801219</link>
      <description>Hi All - I have a file that I want to add a line into. This line needs to be added after the line starting with the word "History".&lt;BR /&gt;I believe sed can do this but I cant figure out how to get it to work. Any ideas would be appreciated.&lt;BR /&gt;thanks John</description>
      <pubDate>Wed, 07 Feb 2001 02:48:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490604#M801219</guid>
      <dc:creator>John McWilliams</dc:creator>
      <dc:date>2001-02-07T02:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490605#M801220</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Your task can be accomplished easily with perl:&lt;BR /&gt;&lt;BR /&gt;==&lt;BR /&gt;[root@cc0070 /root]# cat infile&lt;BR /&gt;abc&lt;BR /&gt;History&lt;BR /&gt;def&lt;BR /&gt;History abcdef abcdef&lt;BR /&gt;abc&lt;BR /&gt;abc&lt;BR /&gt;a History a b c d e&lt;BR /&gt;b History a b c d e&lt;BR /&gt;[root@cc0070 /root]# ./testperl &lt;BR /&gt;[root@cc0070 /root]# cat outfile&lt;BR /&gt;abc&lt;BR /&gt;History&lt;BR /&gt;INSERTED_TEXT&lt;BR /&gt;def&lt;BR /&gt;History abcdef abcdef&lt;BR /&gt;INSERTED_TEXT&lt;BR /&gt;abc&lt;BR /&gt;abc&lt;BR /&gt;a History a b c d e&lt;BR /&gt;b History a b c d e&lt;BR /&gt;You have new mail in /var/spool/mail/root&lt;BR /&gt;[root@cc0070 /root]# cat testperl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt; &lt;BR /&gt;open (INFILE, "infile");&lt;BR /&gt;open (OUTFILE, "&amp;gt;outfile");&lt;BR /&gt;while (&lt;INFILE&gt;)&lt;BR /&gt;{&lt;BR /&gt;  $_ =~s/^History(.*)/History\1\nINSERTED_TEXT/g;&lt;BR /&gt;  print OUTFILE $_;&lt;BR /&gt;}&lt;BR /&gt;==&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/INFILE&gt;</description>
      <pubDate>Wed, 07 Feb 2001 03:52:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490605#M801220</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-02-07T03:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490606#M801221</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To add 3 lines after all lines that begin with History:&lt;BR /&gt;&lt;BR /&gt;sed -e '/^History/aline to add #1line to add #2line to add #3' file&lt;BR /&gt;&lt;BR /&gt;Note the single quotes and the backslashes \.  They are important.&lt;BR /&gt;&lt;BR /&gt;If you have multiple History lines and only want to append after the first, it gets more complex and requires two sed commands (at least by me - sed gurus may be able to do it in one command).&lt;BR /&gt;&lt;BR /&gt;sed -e '/^History/aline to add #1line to add #2line to add #3' -e '/^History/d' file &amp;gt; file.tmp&lt;BR /&gt;&lt;BR /&gt;sed -e '1,/^History/d' file &amp;gt;&amp;gt; file.tmp&lt;BR /&gt;&lt;BR /&gt;Disclaimer:  I read the HP man pages but tested this on a Linux box.  It *should* work on HP-UX.&lt;BR /&gt;&lt;BR /&gt;--Bruce</description>
      <pubDate>Wed, 07 Feb 2001 03:53:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490606#M801221</guid>
      <dc:creator>Bruce Regittko_1</dc:creator>
      <dc:date>2001-02-07T03:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490607#M801222</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;Arrrgghh!  Apparently the reply interface doesn't handle lines ending in a backslash well.  The correctly formatted sed commands are in the attachment.&lt;BR /&gt;&lt;BR /&gt;--Bruce</description>
      <pubDate>Wed, 07 Feb 2001 04:07:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490607#M801222</guid>
      <dc:creator>Bruce Regittko_1</dc:creator>
      <dc:date>2001-02-07T04:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490608#M801223</link>
      <description>You can also do this with 'ed':&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;cat - &amp;lt;&amp;lt; EOF | ed -s file_to_edit&lt;BR /&gt;/History&lt;BR /&gt;+1&lt;BR /&gt;i&lt;BR /&gt;New Line of text&lt;BR /&gt;.&lt;BR /&gt;w&lt;BR /&gt;q&lt;BR /&gt;EOF&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Feb 2001 09:05:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2490608#M801223</guid>
      <dc:creator>Tommy Palo</dc:creator>
      <dc:date>2001-02-07T09:05:20Z</dc:date>
    </item>
  </channel>
</rss>

