I have two directories, say A/ and B/, each with their own subtree. I'd need to synchronize the content of A/ with the content of B/. The result I need is similar to recursively copying the subtree of B/ into A/ with cp -r, except that instead of actually copying the data from B/, I want to create symlinks in A/ which point to the files in B/.

My question is, is there a simple way/command/tool to do this or I have to create B/'s subtree in A/ and then go over all B/s files and create the symlinks? The best would be to be able to use rsync as a symlink creator and then just the delta symlinks would be created, but I don't think this is possible.


With 2 commands you could achive this: here is an example to clone directory structure of /etc and create symlinks for all files in /etc:

# create directories
find /etc -type d -exec mkdir .{} \;

# symlink files
find /etc -type f -exec ln -s {} .{} \;
  • any chance to speed up the process and only create the symlink that are not already there? B/ is constantly changing and I need to update the symlinks in A/ from time to time, accordingly. Could you think of any method to update the symlinks incrementally, like rsync would do with the files? – Botond Jul 2 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.