How to Copy Directory Structure Without Files in Unix and Linux

In some scenarios, you might want to mimic a certain directory structure that already exists maybe for your personal projects or for a files storage system just because that directory structure makes perfect sense and might require a lot of time to completely recreate it from scratch.


Following is the cool way of copying a directory structure without files from already populated directory files in Unix and Linux OS.

find . -type d | cpio -pdvm <Destination path>

FYI, please change directory(cd) to source path before executing above command.

Leave a Comment