Why are hard links are not updated when modified with an editor

hard link

I am using Mac OS X, but the command line. I want to make a link from my .profile file, to another file on my system so that updating one updates the other and vice versa.

This article makes me think that a hard link is what I need. The command I have been using is:

ln .profile ~/Newpath/.profile

This kind of works, in that a file is created at Newpath, however, updating one file does not automatically update the other nor vice versa.

I have tried ln with simple files on my desktop, and the links do indeed update each other. I am wondering if anybody has experience with links not working with dot files or with files in their home directory on Mac for some reason.

Any idea what could be going on here?

Best Answer

Beware that many editors write to a temporary file and rename finally to the target file.

This will cause your hard-linking to be lost.

Related Question