Ok, this has me banging my head. In OS X, to create a hard link, in a terminal window, you're supposed to be able to just type this…
ln a.txt b.txt
…and this should create a hard link from a.txt
to b.txt
. Simple and straight forward.
When I execute that statement, sure enough, in Finder b.txt
appears right alongside a.txt
. However, even after editing a.txt
using TextEdit, b.txt
still has the original data! In other words, it looks like it performed a copy, not a link, hard or otherwise.
Makes no damn sense to me! So can someone tell me what I'm doing wrong here?
Best Answer
The reason for this behavior is rather straightforward, and it relates to how files are saved in most Mac OS X applications: Atomically.
What happens is that a copy of the file is written to a temporary staging area, and then moved to replace the original file.
This, quite naturally, breaks hard links.