Operating System - HP-UX
1833589 Members
5369 Online
110061 Solutions
New Discussion

Re: How to copy file? but it still preserve old modify date.

 
natis
Frequent Contributor

How to copy file? but it still preserve old modify date.

How to copy file? but it still preserve old modify date. Please, suggest me.
6 REPLIES 6
Rob Leadbeater
Honored Contributor

Re: How to copy file? but it still preserve old modify date.

Maybe "cp -p "

Cheers,

Rob
Oviwan
Honored Contributor

Re: How to copy file? but it still preserve old modify date.

Hey

check man cp:
-p (preserve permissions) Causes cp to preserve in the copy as
many of the modification time, access time, file mode, user
ID, and group ID as allowed by permissions.


$cp -p yourfile

Regards
Dennis Handly
Acclaimed Contributor

Re: How to copy file? but it still preserve old modify date.

If you have lots of files, you can use tar to save this info. If you aren't root, you can use tar -p when you extract to try to keep the original modes and ownership. (Similar to cp -p that Rob and Oviwan mentioned.)
Pete Randall
Outstanding Contributor

Re: How to copy file? but it still preserve old modify date.

Most any of the commands used to copy files (cp, rcp, scp, cpio and all the others) have a -p switch which can be used to preserve "permissions", as in time stamps. A quick check of the man pages for your command of choice should give you your answer.


Pete

Pete
TwoProc
Honored Contributor

Re: How to copy file? but it still preserve old modify date.

For moving things from server to server, or file system to file system, and keeping everything the same(time, ownership, permissions), my favorite tool is tar. If you must, for some reason, move special files (e.g. /dev/dsk/c0t1d02), then my favorite tool is cpio.
We are the people our parents warned us about --Jimmy Buffett
Sp4admin
Trusted Contributor

Re: How to copy file? but it still preserve old modify date.

You should beable to use "cp -pR".

sp,