2008/6/2 Marieke Thayer <[EMAIL PROTECTED]>: > Hi all, > > Can any of you tell me how to preserve the date on the new copy of a file > when you use the cp command in bash? > > Kubuntu 8.04 > > I tried > > cp -p tmp.txt tmp2.txt > cp -a tmp.txt tmp2.txt > cp --preserve=timestamps tmp.txt tmp2.txt
What evidence do you have that "cp -p" is not preserving the time/date information? Every file has three associated dates. When it was last accessed (atime) When it was last modified (mtime) When its status was last changed (ctime) My experiments with "cp -p" indicate that this command preserves the mtime. It changes the atime of the source, since the source has just been accessed, and copies the old atime of the source to the destination. (preserving it) The ctime of the destination is different, because the destination file has a new status, namely it now exists. The command "ls -l" with no other qualifying flags displays the mtime. For perhaps more than you wanted to know, look at <http://en.wikipedia.org/wiki/Stat_(Unix)> carl -- carl lowenstein marine physical lab u.c. san diego [EMAIL PROTECTED] -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-newbie
