up vote 0 down vote favorite
share [g+] share [fb]

If I copy some file from some place to another using cp, the timestamp on the copied file is set to the time of the copy.

Is there some way to avoid this?

I need to copy files without altering their timestamps.

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

cp -p does the trick.

link|improve this answer
@Arjan van Bentem: thanks! – Lazer Feb 27 '10 at 14:04
cp -a is also nice to know, it implies not only -p, but also -R to copy entire directories and -d to preserve links. – casualuser Feb 27 '10 at 20:53
feedback

There are three times on a Unix filesystem, the access time (atime), the modification time (mtime), and the inode change time (ctime). You can change the access time and the modification time with the touch program, for example

cp orig copy
touch -r orig copy

However, you cannot change the inode change time.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.