One Quickie


Updating critical system files while preserving the original timestamp (Unix->Administration)
Sometimes you need to edit a file, like /etc/rc, but you want to be able to back out your changes. You also want to preserve the original timestamp of the file. That way if you back out your change, someone else coming along doesn't have to figure out "why did /etc/rc change yesterday, it doesn't look any different?" Here's how:
  1. Move (not copy) the original to a backup name. This will preserve the timestamp: % sudo mv rc rc-orig

  2. Copy the original to the usual name: % sudo cp rc-orig rc

  3. make your edits: % sudo vi rc
If you decide your changes aren't worth keeping, you would move the original back:
% sudo mv rc-orig rc

Thereby undoing your changes, and not messing up the timestamp of the original file.

(mucho thankos to Louis Bertrand for this one)



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com