Linux – How to copy a single file and maintain directory structure file managementlinux How can I do this on the command line? e.g. copy /dir/another/file to /tmp/ so I have /tmp/dir/another/file Best Answer cp --parents /dir/another/file /tmp will do exactly what you want. Related SolutionsMacos – Copy directory structure without copying files, on Mac OS X user@osx:~/from$ find . -type d -exec mkdir -p ~/to/{} \; user@osx:~/from$ find . -type f -exec ln -s ~/from/{} ~/to/{} \; or user@osx:~/from$ find . -type f -exec touch ~/to/{} \; How to Recursively Copy Files by Extension While Preserving Directory Structure You can use find and cpio to do this cd /top/level/to/copy find . -name '*.txt' | cpio -pdm /path/to/destdir (-updm for overwrite destination content.) Related QuestionLinux – How to Copy Files Recursively Ignoring Destination Directory Structure
Best Answer
will do exactly what you want.