Wednesday, December 10, 2014

How to copy a specific file type keeping the folder structure intact in the destination directory

By using cpio command in pass through mode, files can be copied to the destination directory with the same path structure as in the source directory

find /source_path/of/files -name "<regex_of_filetype>" | cpio -pdm /destination_directory_path

Eg: To copy all files of type "*.sh" in /home/bob to /tmp/jim, keeping the source directory path of files in destination intact


find /home/bob -type f -name "*.sh" | cpio -pdm /tmp/jim

No comments:

Post a Comment