Macos – How to create hard links in OSX

hardlinkmacosunix

What I want is to have multiple copies of the same file, and whenever I edit one of them, they all get updated. I thought Hard Links would solve my problem. So, I used the command ln as described in Wikipedia. However, when I changed the original file, the linked one didn't change.

Did I misunderstand what hard links are supposed to do?

  • If yes:
    • Then what's the difference between ln and cp?
    • How can I do what I want?
  • If no:
    • Why didn't it work?
    • How can I get it to work?

Best Answer

Perhaps the editor is doing some weird things, like copying the file to some temporary location, or whatever.

My suggestion would be on the contrary: Edit the file using always the same path, and use symbolic links (ln -s) everywhere.

And version control systems might be relevant too.

Related Question