Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pizzacake

macrumors member
Original poster
Sep 13, 2006
74
0
I'm running OS X Leopard 10.5.4 on an Intel iMac.

In my user directory I create a text file called firstTextFile and list the directory's contents

imac:~ me$ ls -l ~/
-rw-r--r--@ 1 me staff 354 11 Sep 20:26 firstTextFile.rtf

then I create a hard link to this firstTextFile

imac:~ me$ ln /Users/me/firstTextFile.rtf secondTextFile.rtf

then list directory contents

imac:~ me$ ls -l ~/
-rw-r--r--@ 2 me staff 354 11 Sep 20:26 firstTextFile.rtf
-rw-r--r--@ 2 me staff 354 11 Sep 20:26 secondTextFile.rtf

the 2 indicates they are hard linked (pointers) to the same data

now I modify firstTextFile and save it

then list directory contents

imac:~ me$ ls -l ~/
-rw-r--r--@ 1 me staff 363 11 Sep 20:31 firstTextFile.rtf
-rw-r--r--@ 1 me staff 354 11 Sep 20:26 secondTextFile.rtf

now the two files are unlinked separate files. I always thought if I open a hard link and modify it when I open the other hard links they also would be modified as all these hard links point to the same data. Anyone know what's going on?
 
How you modify matters. Many editors delete and recreate the file, so the hard linking is lost (unlinked). Try a low level editor and see if that just modifies the file without deleting/creating-with-same-name.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.