|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Preserve timestamp
Hi,
I want to replace file a with file b. I normally just cp b a or mv b a depending on exactly what I want to do. This time though I want to cp b a but I want to preserve the date/time information of file a. Is this possible and if so how ? Thanks Simon |
|
#2
|
|||
|
|||
|
The inode of a file has 3 timestamps atime, mtime, and ctime. You can set the first two to anything (via the touch command). ctime cannot be changed even by root. See "man touch". When you do your "cp b a", do you want "a" to have the original timestamp of "b" or the original timestamp of "a". If the former, there are some tools like tar that can do this. But for the latter, you will need your own script based on "touch".
|
|
#3
|
|||
|
|||
|
You can use the copy command with -p option.
Refer to the man for more info - -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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Preserve timestamp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|