How to create a shadow directory
As well as by using ln
, you can also make symbolic links to files with cp
by using the -s
flag. This is useful, because this still works with the -r
and -a
flags, meaning you can clone an entire tree of symlinks, from D to D1.
To work correctly, D must be an absolute path, or converted to one by using $(realpath D)
.
Putting this all together:
cp -asT "$(realpath D)" D1
To be clear, editing files in D1 will still change the originals in D, but links in D1 can be safely deleted.