This is something I do a lot, and I've been using an older tool to do this. Rsync should do it, too. mkdir a b touch a/file1 a/file2 rsync -a --new-option a b would create b/a/file1 b/a/file2 as shared links to their counterparts in a/
Just pass a --link-dest option for the source dir.
OK, but 1. an option specifically for this is warranted. 2. the new option would operate quite differently from using link_dest, as below --clone hard links the destination to the source. If necessary, each existing destination file is removed first. It is an error to use this option unless src and dest are on the same volume.
(In reply to comment #2) > 1. an option specifically for this is warranted. Why? > 2. the new option would operate quite differently from using link_dest, as > below > > --clone hard links the destination to the source. If necessary, each existing > destination file is removed first. The --recheck-basis-dirs option of bug 5644 would make --link-dest work that way. > It is an error to use this option unless src > and dest are on the same volume. Is it really important for rsync to issue an error in this case?
I personally don't see the need for this as a special option.