From LQWiki
Jump to: navigation, search

It seems that if you edit a hard link, that the result of the edit isn't that both files are changed (what I would expect), but rather, that a duplicate is made and modified.

Is this correct, or us emacs just being clever, and making a new file just like the original?


That stumps me, which means "take it to the LQ forums". Crazyeddie 20:08, Aug 16, 2004 (EDT)

It's just emacs. For example:

$ echo "Contents of file 1." > file1
$ ln file1 file2
$ cat file2
Contents of file 1.
$ echo "Contents of file 2." > file2
$ cat file1
Contents of file 2.

With emacs, the original, crosslinked file is saved with a tilde (~).

$ emacs file1       # Change the contents, save, and exit
$ ls -l
-rw-rw-r--    1 Snags    Snags          19 Aug 17 14:56 file1
-rw-rw-r--    2 Snags    Snags          19 Aug 17 14:56 file1~
-rw-rw-r--    2 Snags    Snags          19 Aug 17 14:56 file2

The number just before the username is the number of hard links. --Snags 15:02, Aug 17, 2004 (EDT)