Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to perform what rsync does (compiles many directories into a single directory) - But instead of copying files/sub-directories I need it to create a directory with symlinks that point to the original files/sub-directories.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Your question is ambiguous.

cp -l "$SRCDIR"/* "$DESTDIR"

find "$SRCDIR" -mindepth 1 \( -type d -printf 'mkdir "$DESTDIR/%P"\n' \) -o \
  \( -printf 'cp -l "%p" "$DESTDIR/%P"\n' \) | DESTDIR="$DESTDIR" bash

The first creates symlinks to the various items directly in $SRCDIR. The second recreates the directory structure and creates symlinks to the non-directories.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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