<?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: Copying files for different instance names in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485906#M363151</link>
    <description>Hi (again) Shiv:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Sorry James for misunderstanding!! I am interested in solutions.&lt;BR /&gt;I was just exploring if it was possible and not rigid on a specific solutions.&lt;BR /&gt;&lt;BR /&gt;Then please accept my apology for mis-reading your query!  Sometimes of late, you never know.  I am a believer in TMTOWTDI and I should have taken your question in that context.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 25 Aug 2009 23:10:05 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-08-25T23:10:05Z</dc:date>
    <item>
      <title>Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485900#M363145</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I need to copy a log file from /logs/{instance-name}/abc.log-08222009 to  /tmp/&lt;BR /&gt;&lt;BR /&gt;As "abc.log-08222009" name is same for all the instances it overwrites after copying to /tmp/ directory.&lt;BR /&gt;&lt;BR /&gt;I want to append the instance name from source and assign it to destination file name.&lt;BR /&gt;&lt;BR /&gt;Say for example:&lt;BR /&gt;&lt;BR /&gt;cp /logs/venus/abc.log-08222009 /tmp/abc.log-08222009-venus&lt;BR /&gt;&lt;BR /&gt;cp /logs/moon/abc.log-08222009 /tmp/abc.log-08222009-moon&lt;BR /&gt;&lt;BR /&gt;As there are hundred of different instance names i want to copy using single command to save time.&lt;BR /&gt;&lt;BR /&gt;Can someone suggest proper command or script ?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Aug 2009 21:06:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485900#M363145</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2009-08-25T21:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485901#M363146</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;I can suggest a structure.&lt;BR /&gt;&lt;BR /&gt;Make a file list and then process it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ls -1 &amp;gt; list&lt;BR /&gt;&lt;BR /&gt;while read -r fn&lt;BR /&gt;do&lt;BR /&gt;    cp $fn /tmp/instance&lt;BR /&gt;done &amp;lt; list&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can expand on this.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 25 Aug 2009 21:32:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485901#M363146</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2009-08-25T21:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485902#M363147</link>
      <description>&lt;!--!*#--&gt;Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;This is trivial with Perl.&lt;BR /&gt;&lt;BR /&gt;# cat ./mycopy&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use File::Copy;&lt;BR /&gt;my ( $oldname, $newname );&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp( $oldname = $_ );&lt;BR /&gt;    ( $newname = $oldname ) =~ s{/logs/(.+)/(.+)}{/tmp/$2-$1};&lt;BR /&gt;    copy( $oldname, $newname ) or warn "Can't copy '$oldname': $!\n";&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;You can feed the "old" filenames (those to be copied) from a pipe or as an input file:&lt;BR /&gt;&lt;BR /&gt;# find /path -type f -name "abc.log*" | ./mycopy&lt;BR /&gt;&lt;BR /&gt;(or):&lt;BR /&gt;&lt;BR /&gt;# ./mycopy file_of_list_of_files&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 25 Aug 2009 21:52:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485902#M363147</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-25T21:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485903#M363148</link>
      <description>Is single command possible with the combination of awk or sed ?</description>
      <pubDate>Tue, 25 Aug 2009 21:59:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485903#M363148</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2009-08-25T21:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485904#M363149</link>
      <description>Hi (again) Shiv:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Is single command possible with the combination of awk or sed ?&lt;BR /&gt;&lt;BR /&gt;How long a command line do you want?  How obtuse do you want to make it?  What will you do everytime you want to use it?  Why do you ask for 'awk' or 'sed' --- you could manage parts of your objective in either since 'awk' has a 'system()' function and 'sed' can do regular expression backreferences but neither can do both like Perl.&lt;BR /&gt;&lt;BR /&gt;HENCE, do you want a solution or do you want to tell us the only way you want your problem solved?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Aug 2009 22:07:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485904#M363149</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-25T22:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485905#M363150</link>
      <description>Sorry James for misunderstanding!! I am interested in solutions. &lt;BR /&gt;I was just exploring if it was possible and not rigid on a specific solutions.</description>
      <pubDate>Tue, 25 Aug 2009 23:02:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485905#M363150</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2009-08-25T23:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485906#M363151</link>
      <description>Hi (again) Shiv:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Sorry James for misunderstanding!! I am interested in solutions.&lt;BR /&gt;I was just exploring if it was possible and not rigid on a specific solutions.&lt;BR /&gt;&lt;BR /&gt;Then please accept my apology for mis-reading your query!  Sometimes of late, you never know.  I am a believer in TMTOWTDI and I should have taken your question in that context.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 25 Aug 2009 23:10:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485906#M363151</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-25T23:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485907#M363152</link>
      <description>No Problem. &lt;BR /&gt;Your help and contribution has benefitted me lot on this forum.&lt;BR /&gt;This forum keeps HP-UX ahead of others.</description>
      <pubDate>Wed, 26 Aug 2009 00:26:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485907#M363152</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2009-08-26T00:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Copying files for different instance names</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485908#M363153</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I want to append the instance name from source and assign it to destination file name.&lt;BR /&gt;cp /logs/venus/abc.log-08222009 /tmp/abc.log-08222009-venus&lt;BR /&gt;&lt;BR /&gt;For this exact pattern you can use:&lt;BR /&gt;for file in /logs/*/abc.log*; do&lt;BR /&gt;   new_file=$(echo $file | sed -e 's:/logs/\([^/]*\)/\(.*\):\2-\1:')&lt;BR /&gt;   cp $file /tmp/$new_file&lt;BR /&gt;done</description>
      <pubDate>Wed, 26 Aug 2009 03:22:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/copying-files-for-different-instance-names/m-p/4485908#M363153</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-08-26T03:22:16Z</dc:date>
    </item>
  </channel>
</rss>

