6

I would like to change the modified date of a symlink. The symlink points to a directory so it cannot be a hardlink. The following command works fine in the terminal for an actual directory, but it does not modify the modified date on the symlink. How can I do this and why does the command not work on symlinks?

touch -mt 201202112109 "Users/scott/actual directory"
touch -mt 201202112109 "Users/scott/symlink"

First one works, second one does not. the symlink actually points to the directory with the modified mod date. both are owned by same owner (me) and have same permissions. Running Lion 10.7.3

  • The default disk format (HFS+) for OS X does support hard links for directories – Mark Dec 3 '14 at 15:55
6

You need to add the '-h' parameter to modify symbolic link timestamps.

In your case:

touch -mht 201202112109 "Users/scott/symlink"

Without the '-h' the timestamp of the file that is linked to is modified.

  • Hooray for man pages! – Christian L Feb 12 '12 at 5:29
  • I almost never use the man page from the terminal, I prefer the html man pages at developer.apple.com. I did check there - the latest version choice is 10.6.6 and it does not reference th -h flag. Lesson learned, but I did not just throw a question up without some research first. – Scott Feb 13 '12 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .