Wednesday, February 18, 2015

Use rsync to copy a directory structure

To copy the directory structure only without copying any files:

rsync -a -f"+ */" -f"- *" source destination/

If you don't put the trailing / on source you'll get the source directory created in destination. If you put the trailing / after source, you'll get all of the subdirectories of source created in destination without the top source directory.