<?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: cp files only preserving timestamp in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768519#M43983</link>
    <description>On RHEL 5 and probably all equivalent or newer Linux distributions:&lt;BR /&gt;&lt;BR /&gt;cp --preserve=timestamps /source/dir/*.srf /destination/dir/&lt;BR /&gt;&lt;BR /&gt;Since there is no option "-r", directories will not be copied: the cp command will output "cp: omitting directory /source/dir/something.srf" if it finds a directory that would match the *.srf wildcard. But this is information only.&lt;BR /&gt;&lt;BR /&gt;If there are more files than will fit on a single command line (i.e. the above command will produce a shell error message because wildcard expansion fails), a bit more is needed. For example:&lt;BR /&gt;&lt;BR /&gt;Create a script /usr/local/bin/cpto, to allow specifying the copy destination first:&lt;BR /&gt;----&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;DEST="$1"&lt;BR /&gt;shift&lt;BR /&gt;cp "$@" "$DEST"&lt;BR /&gt;----&lt;BR /&gt;chmod a+x /usr/local/bin/cpto&lt;BR /&gt;&lt;BR /&gt;Then, perform the copy operation:&lt;BR /&gt;&lt;BR /&gt;cd /source/dir&lt;BR /&gt;ls -l | grep '^-.*\.srf$' | awk '{print $9;}' | xargs /usr/local/bin/cpto /destination/dir&lt;BR /&gt;&lt;BR /&gt;This is not limited by maximum command line length, like shell wildcard expansions are.&lt;BR /&gt;&lt;BR /&gt;MK</description>
    <pubDate>Wed, 23 Mar 2011 13:54:14 GMT</pubDate>
    <dc:creator>Matti_Kurkela</dc:creator>
    <dc:date>2011-03-23T13:54:14Z</dc:date>
    <item>
      <title>cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768515#M43979</link>
      <description>Hi there&lt;BR /&gt;I need to copy files from a directory which has some sub directories in it. The problem is that I need only files - no directories and only files of certain extension ( *.srf ). Also i need to preserve the original time-stamp. &lt;BR /&gt;How can this be accomplished ?</description>
      <pubDate>Tue, 22 Mar 2011 14:41:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768515#M43979</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2011-03-22T14:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768516#M43980</link>
      <description>I'm pretty sure tar will preserve times for you, if I remember correctly.&lt;BR /&gt;&lt;BR /&gt;--------------------------------------&lt;BR /&gt;Example: From computer to another computer &lt;BR /&gt;&lt;BR /&gt;On source computer&lt;BR /&gt;$&amp;gt;find /mysource -type f -name "*.srf" | xargs -i tar cvf myfiles.tar {} &lt;BR /&gt;&lt;BR /&gt;Copy tar file to other computer, then extract from the tar file.&lt;BR /&gt;$&amp;gt; cd mydestination&lt;BR /&gt;$&amp;gt; tar xvf myfiles.tar&lt;BR /&gt;----------------------------------------&lt;BR /&gt;Example same computer, two diff directories&lt;BR /&gt;$&amp;gt; cd /mydestination&lt;BR /&gt;$&amp;gt;find /mysource -type f -name "*.srf" | xargs -i tar cvf - {} | tar xvf - &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Mar 2011 15:14:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768516#M43980</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2011-03-22T15:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768517#M43981</link>
      <description>If you do not want to look in the subdirectories for "srf" files to copy then all you need is&lt;BR /&gt;&lt;BR /&gt;/bin/cp -p *.srf /destination/directory/&lt;BR /&gt;&lt;BR /&gt;If you want srf files from the subdirectories too, then perhaps&lt;BR /&gt;&lt;BR /&gt;/usr/bin/find /directory -type f -name "*.srf" -exec /bin/cp -p {} /destination \;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Mar 2011 00:24:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768517#M43981</guid>
      <dc:creator>Randy Jones_3</dc:creator>
      <dc:date>2011-03-23T00:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768518#M43982</link>
      <description>&lt;!--!*#--&gt;&amp;gt; If you do not want [...]&lt;BR /&gt;&lt;BR /&gt;&amp;gt; If you want [...]&lt;BR /&gt;&lt;BR /&gt;If you described better exactly what you wish&lt;BR /&gt;to do, then we might avoid some of the&lt;BR /&gt;guessing.  For example:&lt;BR /&gt;&lt;BR /&gt;Where are (all) the files now?&lt;BR /&gt;&lt;BR /&gt;Where would you like (all) the files to be?&lt;BR /&gt;&lt;BR /&gt;Which information would you like preserved?</description>
      <pubDate>Wed, 23 Mar 2011 03:05:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768518#M43982</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-03-23T03:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768519#M43983</link>
      <description>On RHEL 5 and probably all equivalent or newer Linux distributions:&lt;BR /&gt;&lt;BR /&gt;cp --preserve=timestamps /source/dir/*.srf /destination/dir/&lt;BR /&gt;&lt;BR /&gt;Since there is no option "-r", directories will not be copied: the cp command will output "cp: omitting directory /source/dir/something.srf" if it finds a directory that would match the *.srf wildcard. But this is information only.&lt;BR /&gt;&lt;BR /&gt;If there are more files than will fit on a single command line (i.e. the above command will produce a shell error message because wildcard expansion fails), a bit more is needed. For example:&lt;BR /&gt;&lt;BR /&gt;Create a script /usr/local/bin/cpto, to allow specifying the copy destination first:&lt;BR /&gt;----&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;DEST="$1"&lt;BR /&gt;shift&lt;BR /&gt;cp "$@" "$DEST"&lt;BR /&gt;----&lt;BR /&gt;chmod a+x /usr/local/bin/cpto&lt;BR /&gt;&lt;BR /&gt;Then, perform the copy operation:&lt;BR /&gt;&lt;BR /&gt;cd /source/dir&lt;BR /&gt;ls -l | grep '^-.*\.srf$' | awk '{print $9;}' | xargs /usr/local/bin/cpto /destination/dir&lt;BR /&gt;&lt;BR /&gt;This is not limited by maximum command line length, like shell wildcard expansions are.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Wed, 23 Mar 2011 13:54:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768519#M43983</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-03-23T13:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768520#M43984</link>
      <description>"cp --preserve=timestamps /source/dir/*.srf /destination/dir/"&lt;BR /&gt;&lt;BR /&gt;This will copy all the files and directories. I need to get only *.srf files from certain directory and it's sub directories preserving the original time-stamp.&lt;BR /&gt;Reagrds&lt;BR /&gt;Peter</description>
      <pubDate>Wed, 23 Mar 2011 18:55:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768520#M43984</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2011-03-23T18:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768521#M43985</link>
      <description>This command won't take you through the subdirectories, and neither will add the "-R" command to the mix for the cp command.&lt;BR /&gt;&lt;BR /&gt; "cp --preserve=timestamps /source/dir/*.srf /destination/dir/"&lt;BR /&gt;&lt;BR /&gt;Thus, you'll have to go back to the find|xargs|tar command I posted above.  The reason I recommend tar is that it does preserve timestamps on recovery.  See my perfectly working 4 point suggestion with options posted above. :)</description>
      <pubDate>Thu, 24 Mar 2011 16:25:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768521#M43985</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2011-03-24T16:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: cp files only preserving timestamp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768522#M43986</link>
      <description>&lt;!--!*#--&gt;&amp;gt; See my perfectly working 4 point suggestion&lt;BR /&gt;&amp;gt; [...]&lt;BR /&gt;&lt;BR /&gt;I'll see your 4-point suggestion and raise&lt;BR /&gt;you my 0-point request for a problem&lt;BR /&gt;statement which was clear enough that a&lt;BR /&gt;non-psychic could understand what the actual&lt;BR /&gt;task was.&lt;BR /&gt;&lt;BR /&gt;For example, does "I need only files - no&lt;BR /&gt;directories" mean that all the files from&lt;BR /&gt;many source directories should end up in one&lt;BR /&gt;destination directory?  It's a mystery which&lt;BR /&gt;only one person can resolve.  And he's not&lt;BR /&gt;talking.  (Or, if he is, then he's not saying&lt;BR /&gt;anything which I can understand.  But my&lt;BR /&gt;opinion is apparently worthless.)</description>
      <pubDate>Thu, 24 Mar 2011 17:51:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cp-files-only-preserving-timestamp/m-p/4768522#M43986</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-03-24T17:51:49Z</dc:date>
    </item>
  </channel>
</rss>

