Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I set the time information of a file to be the same as of another file on OSX / Linux?

share|improve this question
add comment

1 Answer

up vote 23 down vote accepted

Type:

touch -r FILE1 FILE2

That sets the access and modification times of FILE2 to match FILE1.

share|improve this answer
9  
And note: the infamous "creation time" (aka "ctime") that might hear people say that UNIX systems store for a file is really the "i-node modification time", which virtually useless, and certainly doesn't represent the time the file was created. –  Fran Jun 16 '12 at 15:47
4  
The real "creation time" is btime aka "birth time", which some filesystems support but Linux stat() doesn't (yet). –  grawity Jun 16 '12 at 16:07
    
when using touch -r on OSX, the "creation time" (as appears in the "get info" box for a file) becomes the same as "last modified" time. i.e. it seems that the FILE1 creation time gets ignored/lost in the process –  GJ. Jun 17 '12 at 11:38
1  
@Fran I wasn't aware of how ctime works. I found a good explanation of it here. http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html –  Joe Jun 18 '12 at 19:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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