symlink-copying a directory hierarchy

Max Spring picture Max Spring · Aug 6, 2009 · Viewed 16.5k times · Source

What's the simplest way on Linux to "copy" a directory hierarchy so that a new hierarchy of directories are created while all "files" are just symlinks pointing back to the actual files on the source hierarchy?

cp -s does not work recursively.

Answer

freiheit picture freiheit · Aug 9, 2009

I just did a quick test on a linux box and cp -sR /orig /dest does exactly what you described: creates a directory hierarchy with symlinks for non-directories back to the original.