I have a file, myfile.txt, located in folder1. From the terminal I create a hard link to this file in another directory with the command
ln myfile.txt ~/Documents/folder2
The new file appears as expected in folder2. When I examine the inode for each file using ls -i, it gives the same number, as expected. However, if I open the file and modify it in folder1, after saving, if I open the file from folder2 it has no data. Investigating the inode numbers with ls -i, the two files now have different inode numbers. So my question is, why is this happening? Is this the behavior I should be expecting? My understanding was that hard links were truly indistinguishable files, merely alternate names for the same data. Thus I would expect that altering the file after opening in one location wouldn't be any different than had I opened it from the other location. Can anyone explain what is going on here?
In event that it matters, I'm using Mavericks and the default terminal.app.
Some additional information. The described behavior happened when the file was edited with either TeXShop or TextEdit, so I thought it was something at the OS level. However it appears to not happen when I edit the file with Aquamacs.