<?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: insert text before first line in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331841#M874034</link>
    <description>&lt;BR /&gt;Isn't it a little more tricky to get the newline there?&lt;BR /&gt;&lt;BR /&gt;sed -e '1i\^Jtest^J' file  &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;In this example the ^J stands for a linefeed.&lt;BR /&gt;You can enter this on the command line with a control-V followed by control-J&lt;BR /&gt;&lt;BR /&gt;Alternative using replace instead of insert:&lt;BR /&gt;&lt;BR /&gt;sed '1s/^/test\^J/' file &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;Again ^J is entered as control-v followed by control-j and a \ is needed to escape that.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You may want to check out the "Handy one-liners for SED" file. For example the one attached to:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=630972" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=630972&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 14 Jul 2004 21:29:51 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2004-07-14T21:29:51Z</dc:date>
    <item>
      <title>insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331839#M874032</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am working on Sun OS. I need to enter a text before the first line in a file. How would i accomplish the task using sed.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy</description>
      <pubDate>Wed, 14 Jul 2004 20:43:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331839#M874032</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2004-07-14T20:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331840#M874033</link>
      <description>sed -e '1i\ ' filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Wed, 14 Jul 2004 21:04:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331840#M874033</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-07-14T21:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331841#M874034</link>
      <description>&lt;BR /&gt;Isn't it a little more tricky to get the newline there?&lt;BR /&gt;&lt;BR /&gt;sed -e '1i\^Jtest^J' file  &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;In this example the ^J stands for a linefeed.&lt;BR /&gt;You can enter this on the command line with a control-V followed by control-J&lt;BR /&gt;&lt;BR /&gt;Alternative using replace instead of insert:&lt;BR /&gt;&lt;BR /&gt;sed '1s/^/test\^J/' file &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;Again ^J is entered as control-v followed by control-j and a \ is needed to escape that.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You may want to check out the "Handy one-liners for SED" file. For example the one attached to:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=630972" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=630972&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jul 2004 21:29:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331841#M874034</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-07-14T21:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331842#M874035</link>
      <description>Iam having fun with inserting ^v-^J ;-)&lt;BR /&gt;Or make use of a simple script,&lt;BR /&gt;# cat a.sed&lt;BR /&gt;1i\&lt;BR /&gt;mytext&lt;BR /&gt;&lt;BR /&gt;# sed -f a.sed myfile &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;regds,&lt;BR /&gt;Abdul.</description>
      <pubDate>Wed, 14 Jul 2004 21:37:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331842#M874035</guid>
      <dc:creator>Abdul Rahiman</dc:creator>
      <dc:date>2004-07-14T21:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331843#M874036</link>
      <description>&lt;BR /&gt;I forgot to put in an obligatory perl alternative:&lt;BR /&gt;&lt;BR /&gt;perl -e '@_=&amp;lt;&amp;gt;; print "test\n",@_' x&lt;BR /&gt;&lt;BR /&gt;Here we tell perl to 'slurp' the input into an array @_, print  the new line, and burp the array out again. This may be useful for more elaborated problems.&lt;BR /&gt;&lt;BR /&gt;And just with the shell..&lt;BR /&gt;&lt;BR /&gt;echo "test" &amp;gt; newfile; cat file &amp;gt;&amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jul 2004 21:51:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331843#M874036</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-07-14T21:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331844#M874037</link>
      <description>&lt;BR /&gt;[too bad we can not edit replies]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;before someone else comments, yes I know 'slurpling' in perl is not efficient and does not scale well for large files.&lt;BR /&gt;Same goes for sed.&lt;BR /&gt;The more efficient processing for large files is just read and write in a loop.&lt;BR /&gt;&lt;BR /&gt;perl -pe '$i++||print "test\n"' file &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jul 2004 22:16:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331844#M874037</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-07-14T22:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: insert text before first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331845#M874038</link>
      <description>hai,&lt;BR /&gt;&lt;BR /&gt; We can do it with sed as,&lt;BR /&gt; cat /input file/ | sed -e '1 s/^/&lt;YOURSTRING&gt;\&lt;BR /&gt;/g' &amp;gt; netoutput file&lt;BR /&gt;&lt;BR /&gt; or we can simply do it without sed using temporary files as,&lt;BR /&gt; &lt;BR /&gt; cat input-file /tmp/testfile.log&lt;BR /&gt; echo "&lt;FIRST line="" string=""&gt;" &amp;gt; inputfile&lt;BR /&gt; cat /tmp/testfile.log &amp;gt;&amp;gt; inputfile&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Muthukumar.&lt;/FIRST&gt;&lt;/YOURSTRING&gt;</description>
      <pubDate>Wed, 14 Jul 2004 23:43:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-text-before-first-line/m-p/3331845#M874038</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-07-14T23:43:54Z</dc:date>
    </item>
  </channel>
</rss>

