No, I’m not getting all teary-eyed about something… Instead I’m thinking about changing the modification date stamp on a file. Let’s take a fairly innocuous and hidden file, such as the the COOKIES file located in the /usr/share/emacs/22.1/etc directory. Since I’ve already tried the recipe, I’m going to go ahead and replace the contents of this file with the contents of the mutex script posted a few days ago. This leaves the date the file was created altered as can be seen by doing an ls -al on the file:
-rw-r–r– 1 root wheel 4968 Apr 21 22:04 /usr/share/emacs/22.1/etc/COOKIES
We’re going to go a step further and use stat on the file to see even more information:
234881030 90192 -rw-r–r– 1 root wheel 0 4968 “Apr 21 22:04:01 2009” “Apr 21 22:04:01 2009” “Apr 21 22:04:01 2009” “May 15 16:57:33 2007” 4096 16 0 /usr/share/emacs/22.1/etc/COOKIES
The following command will set the modified date to the same as the creation date (the last of the dates listed:
touch -t 200705151657 /usr/share/emacs/22.1/etc/COOKIES
There are more than likely going to be times when you don’t want to update a file but instead replace it. For example, if we removed COOKIES and then did a curl of a file to /usr/share/emacs/22.1/etc/COOKIES then the Linux version of touch would typically have a -d option, for that pesky creation date, but as the Mac OS X binary nastygrams that it’s an illegal option, we’re going to use the SetFile command. Below, we’ll take whatever file that has been dropped into the appropriate location and then set a new creation time for the file, to match that of the original file:
./SetFile -d “5/15/2007 57:33” /usr/share/emacs/22.1/etc/COOKIES