I have the following filestructure in my src directory:
en/
en/a/
en/a/file1 -> ../../en/mp3/file1-longer-name-a
en/a/file2 -> ../../en/mp3/file2-longer-name-a
en/mp3/file1-longer-name-a
en/mp3/file1-longer-name-b
en/mp3/file2-longer-name-a
en/mp3/file3-longer-name-a
I am interested to copy all the files under en/a/ to the destination, preserving symlinks, and also include the referent files (which BTW are all within en/) but not other files under en/mp3/ if they are not referred by any symlinks I am transferring.
I'm using the following command, that does the obvious part of the job:
rsync -avRz "${SRC}./en/a" "${DST}"
this transfers the following files:
en/
en/a/
en/a/file1 -> ../../en/mp3/file1-longer-name-a
en/a/file2 -> ../../en/mp3/file2-longer-name-a
and I hope you'll help me to tweak the rsync args so that the following files will be transferred too:
en/mp3/file1-longer-name-a
en/mp3/file2-longer-name-a
is there a way to achieve this without needing to write an algorythm to loop over the softlinks under en/a/ and transfer the files they point to one-by-one?
--copy-links
or-L
flag. Instead of copying the symlinks it resolves them and copies the files. But that's not a good idea if you've got many links to one file.