Operating System - HP-UX
1758656 Members
2056 Online
108874 Solutions
New Discussion юеВ

Re: Can cp keep the file Date

 
SOLVED
Go to solution
Steven Chen_1
Super Advisor

Can cp keep the file Date

Hi,

I would like to kwon if cp command can keep the file date so that it suits my reference purpose. Usually it write the current date format.

Thanks anyone.

Steven
Steve
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Can cp keep the file Date

Hi Steven,

use cp -p myfile mycopy

This will preserve most of the attributes; however, mycopy's owner/group will be that of
the user doing the actual copy.

Clay
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Can cp keep the file Date

Hi Steven:

You can add the '-p' flag to your 'cp' command. This will preserve the modification time, access time, file mode, user ID, and group ID as allowed by permissions.

In my $HOME/.profile I have an alias for 'cp' that sets the '-p' and the '-i' flags by default.

Regards!

...JRF...
Nico van Royen
Frequent Advisor

Re: Can cp keep the file Date

the cp -p will also preserve the user permissions. (providinng the user doing the copy has the access right to read the file, and write it down where wanted)..
If all else fails, try reading the manual...
eric stewart_1
Occasional Contributor

Re: Can cp keep the file Date

I would like to see the cp command keep the -p option but would like an option to not copy the owner/group. Maybe -P option, same as -p except for owner/group.
What do others think?