<?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 Shell script: put some text in the first line in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935243#M934858</link>
    <description>Can anyone please tell me what is the best way to add some text to the first line of a file that already exists and has lots of lines? Thank you!</description>
    <pubDate>Tue, 25 Mar 2003 15:51:04 GMT</pubDate>
    <dc:creator>Sharvil Desai</dc:creator>
    <dc:date>2003-03-25T15:51:04Z</dc:date>
    <item>
      <title>Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935243#M934858</link>
      <description>Can anyone please tell me what is the best way to add some text to the first line of a file that already exists and has lots of lines? Thank you!</description>
      <pubDate>Tue, 25 Mar 2003 15:51:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935243#M934858</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2003-03-25T15:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935244#M934859</link>
      <description>There's most likely a better way but this would certainly work:&lt;BR /&gt;&lt;BR /&gt;echo "text" &amp;gt; file.new&lt;BR /&gt;cat file &amp;gt;&amp;gt; file.new&lt;BR /&gt;mv file.new file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Tue, 25 Mar 2003 15:54:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935244#M934859</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-03-25T15:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935245#M934860</link>
      <description>That would work, but I am hoping that someone can think of a better way. If noone can come up with a way then I will gladly accept your answer and assign points. Thank you.</description>
      <pubDate>Tue, 25 Mar 2003 16:05:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935245#M934860</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2003-03-25T16:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935246#M934861</link>
      <description>That would work, but I am hoping that someone can think of a better way. If noone can come up with a better way then I will gladly accept your answer and assign points. Thank you.</description>
      <pubDate>Tue, 25 Mar 2003 16:05:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935246#M934861</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2003-03-25T16:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935247#M934862</link>
      <description>Sharvil,&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;# echo "new first line text here" | cat - yourfile | tee yourfile&lt;BR /&gt;&lt;BR /&gt;Hai&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Mar 2003 16:25:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935247#M934862</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-03-25T16:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935248#M934863</link>
      <description>Sharvil,&lt;BR /&gt;&lt;BR /&gt;if you want to suppress the ouptput from the above command, then try this:&lt;BR /&gt;&lt;BR /&gt;# echo "new first line text here" | cat - yourfile | tee yourfile &amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Tue, 25 Mar 2003 16:29:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935248#M934863</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-03-25T16:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935249#M934864</link>
      <description>Thank you both!&lt;BR /&gt;I like Hai Nguyen's answer.&lt;BR /&gt;Everyone gets points!</description>
      <pubDate>Tue, 25 Mar 2003 16:39:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935249#M934864</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2003-03-25T16:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935250#M934865</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;If you like:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{print "INSERTED_TEXT!"};{print $0}' filename &amp;gt; filename.new&lt;BR /&gt;# mv filename.new filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 25 Mar 2003 16:40:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935250#M934865</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-03-25T16:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935251#M934866</link>
      <description>Just use vi, or your favorite text editor.  &lt;BR /&gt;If you're not familiar with vi, here's a quick primer:&lt;BR /&gt;vi filename&lt;BR /&gt;O (thats capital "O", not zero) to "open" the first line.&lt;BR /&gt;Type your text.&lt;BR /&gt;&lt;ESC&gt;:wq (thats the &lt;ESC&gt; key, followed by the colon, then the w (write) then q (quit).  You're done.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;/ESC&gt;&lt;/ESC&gt;</description>
      <pubDate>Tue, 25 Mar 2003 16:45:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935251#M934866</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2003-03-25T16:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935252#M934867</link>
      <description>it does depend on where you want to add your text, beginning, end, somewhere in the  middle.&lt;BR /&gt;&lt;BR /&gt;you can use sed, awk, ex. to do this.&lt;BR /&gt;&lt;BR /&gt;&lt;FILE&gt;file.tmp&lt;BR /&gt;mv file.tmp file&lt;BR /&gt;use a for appending text&lt;BR /&gt;i for insert text at the begining&lt;BR /&gt;s for subtitution, or changes somewhere in the middle&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Tue, 25 Mar 2003 16:54:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935252#M934867</guid>
      <dc:creator>Curtis Larson_2</dc:creator>
      <dc:date>2003-03-25T16:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script: put some text in the first line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935253#M934868</link>
      <description>using awk&lt;BR /&gt;&amp;lt; file | awk ' {&lt;BR /&gt;if ( NR == 1 ) {&lt;BR /&gt;printf("%s",$0);&lt;BR /&gt;print " your text";}&lt;BR /&gt;else print $0;&lt;BR /&gt;}' &amp;gt; file.tmp&lt;BR /&gt;mv file.tmp file&lt;BR /&gt;&lt;BR /&gt;that will append to the first line or changing the print statements above will insert&lt;BR /&gt;&lt;BR /&gt;printf("%s","your text ");&lt;BR /&gt;print $0;&lt;BR /&gt;&lt;BR /&gt;and of course, awk has several method for adding text somewhere in the middle</description>
      <pubDate>Tue, 25 Mar 2003 17:12:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-put-some-text-in-the-first-line/m-p/2935253#M934868</guid>
      <dc:creator>Curtis Larson_2</dc:creator>
      <dc:date>2003-03-25T17:12:04Z</dc:date>
    </item>
  </channel>
</rss>

