<?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 Playing with files. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282245#M688593</link>
    <description>Hello Experts,&lt;BR /&gt;I am trying to insert a few lines, but unable to proceed further. &lt;BR /&gt;&lt;BR /&gt;Here is the situation.&lt;BR /&gt;Need to Insert a header into multiple files.&lt;BR /&gt;&lt;BR /&gt;For example, the header which needs to be inserted is stored in a file called "header.txt" and the contents of this header.txt ( 5 lines ) needs to be inserted at the beginig (i.e line no 1 )to the all the files. Tried with sed, some how managed to insert a line using"i", but failed to do it using the header.txt as input to the sed command. Kindly show some pointers to achieve this.&lt;BR /&gt;&lt;BR /&gt;ex.&lt;BR /&gt;contents of header.txt&lt;BR /&gt;#-----------------------------------&lt;BR /&gt;# Executes only in HP-UX&lt;BR /&gt;# Author:&lt;XYZ&gt;&lt;BR /&gt;# Date:&lt;DL&gt;&lt;DD&gt;&lt;BR /&gt;#-----------------------------------&lt;BR /&gt;&lt;BR /&gt;above mentioned text needs to be inserted in let us say, 10 shell scripts  ( this won't be empty ).&lt;/DD&gt;&lt;/DL&gt;&lt;/XYZ&gt;</description>
    <pubDate>Tue, 07 Oct 2008 12:45:09 GMT</pubDate>
    <dc:creator>Raghu Chikkamenahalli</dc:creator>
    <dc:date>2008-10-07T12:45:09Z</dc:date>
    <item>
      <title>Playing with files.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282245#M688593</link>
      <description>Hello Experts,&lt;BR /&gt;I am trying to insert a few lines, but unable to proceed further. &lt;BR /&gt;&lt;BR /&gt;Here is the situation.&lt;BR /&gt;Need to Insert a header into multiple files.&lt;BR /&gt;&lt;BR /&gt;For example, the header which needs to be inserted is stored in a file called "header.txt" and the contents of this header.txt ( 5 lines ) needs to be inserted at the beginig (i.e line no 1 )to the all the files. Tried with sed, some how managed to insert a line using"i", but failed to do it using the header.txt as input to the sed command. Kindly show some pointers to achieve this.&lt;BR /&gt;&lt;BR /&gt;ex.&lt;BR /&gt;contents of header.txt&lt;BR /&gt;#-----------------------------------&lt;BR /&gt;# Executes only in HP-UX&lt;BR /&gt;# Author:&lt;XYZ&gt;&lt;BR /&gt;# Date:&lt;DL&gt;&lt;DD&gt;&lt;BR /&gt;#-----------------------------------&lt;BR /&gt;&lt;BR /&gt;above mentioned text needs to be inserted in let us say, 10 shell scripts  ( this won't be empty ).&lt;/DD&gt;&lt;/DL&gt;&lt;/XYZ&gt;</description>
      <pubDate>Tue, 07 Oct 2008 12:45:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282245#M688593</guid>
      <dc:creator>Raghu Chikkamenahalli</dc:creator>
      <dc:date>2008-10-07T12:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with files.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282246#M688594</link>
      <description>&lt;!--!*#--&gt;For that, you don't even need sed.&lt;BR /&gt;&lt;BR /&gt;A small script can do the job:&lt;BR /&gt;&lt;BR /&gt;------------&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;HEADERFILE="$1"&lt;BR /&gt;shift&lt;BR /&gt;&lt;BR /&gt;for FILENAME in "$@"&lt;BR /&gt;do&lt;BR /&gt;    mv "$FILENAME" "$FILENAME.orig" \&lt;BR /&gt;    &amp;amp;&amp;amp; cat "$HEADERFILE" "$FILENAME.orig" &amp;gt;"$FILENAME" \&lt;BR /&gt;    &amp;amp;&amp;amp; rm "$FILENAME.orig"&lt;BR /&gt;done&lt;BR /&gt;------------&lt;BR /&gt;&lt;BR /&gt;Save the script e.g. as "addheader.sh" and use "chmod +x addheader.sh" to mark it executable.&lt;BR /&gt;&lt;BR /&gt;Arguments of this script:&lt;BR /&gt;- first argument: the file that contains the headers&lt;BR /&gt;- all the other arguments: names of files where the header must be added&lt;BR /&gt;&lt;BR /&gt;The maximum number of arguments is limited by the maximum command line length accepted by the OS. As wildcards are expanded by the shell before executing the command line, you can use wildcards as usual.&lt;BR /&gt;&lt;BR /&gt;Examples of use:&lt;BR /&gt;&lt;BR /&gt;./addheader.sh header.txt file1&lt;BR /&gt;&lt;BR /&gt;./addheader.sh header.txt file1 file2 somedir/file3&lt;BR /&gt;&lt;BR /&gt;./addheader.sh header.txt somedir/*.sh&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Tue, 07 Oct 2008 13:10:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282246#M688594</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2008-10-07T13:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with files.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282247#M688595</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Perl will handle your requirements.  You can update your files "in-place" and specify multiple files to be handled in one-pass:&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e 'BEGIN{$header="/tmp/header.txt";open(FH,"&amp;lt;",$header) or die "$!\n";@hdr=&lt;FH&gt;};print @hdr if $.==1;close ARGV if eof' file1 file2 file3...&lt;BR /&gt;&lt;BR /&gt;If you prefer a more readable layout:&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my @hdr;&lt;BR /&gt;BEGIN {&lt;BR /&gt;    my $header = "/tmp/header.txt";&lt;BR /&gt;    open( FH, "&amp;lt;", $header ) or die "$!";&lt;BR /&gt;    @hdr = &lt;FH&gt;;&lt;BR /&gt;}&lt;BR /&gt;print @hdr if $. == 1;&lt;BR /&gt;close ARGV if eof&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as :&lt;BR /&gt;&lt;BR /&gt;# ./filter file1 file2...&lt;BR /&gt;&lt;BR /&gt;That is, pass the file names to be changed.  A backup copy will be retained as &lt;FILE&gt;.old.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/FILE&gt;&lt;/FH&gt;&lt;/FH&gt;</description>
      <pubDate>Tue, 07 Oct 2008 13:11:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282247#M688595</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-07T13:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with files.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282248#M688596</link>
      <description>&lt;!--!*#--&gt;Hi (again):&lt;BR /&gt;&lt;BR /&gt;Ooops, sorry, the "expanded" Perl variation wasn't fully fleshed-out:&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#!/usr/bin/perl -i.old&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my @hdr;&lt;BR /&gt;BEGIN {&lt;BR /&gt;    my $fh;&lt;BR /&gt;    my $header = "/tmp/header.txt";&lt;BR /&gt;    open( $fh, "&amp;lt;", $header ) or die "$!";&lt;BR /&gt;    @hdr = &amp;lt;$fh&amp;gt;;&lt;BR /&gt;}&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    print @hdr if $. == 1;&lt;BR /&gt;    print;&lt;BR /&gt;    close ARGV if eof;&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Oct 2008 12:37:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282248#M688596</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-09T12:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with files.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282249#M688597</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thanks for the pointers. It's really helped a lot to complete my activity.&lt;BR /&gt;&lt;BR /&gt;Many Thanks,&lt;BR /&gt;Regards,&lt;BR /&gt;Raghu</description>
      <pubDate>Fri, 10 Oct 2008 01:43:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/playing-with-files/m-p/4282249#M688597</guid>
      <dc:creator>Raghu Chikkamenahalli</dc:creator>
      <dc:date>2008-10-10T01:43:28Z</dc:date>
    </item>
  </channel>
</rss>

