Recursive copy of specific files in Unix

Post date: Jun 24, 2014 3:15:42 AM

If you want to copy files from a directory and still preserve the structure of the directory including its subdirectories, you can use:

>cp -r /source/ /destination

However, if you want to keep only some specific file extension, you can do

>rsync -avm --include='*.sas' -f 'hide,! */' . /destination

which will copy only .sas files to the destination dir.

See also:

http://stackoverflow.com/questions/14922562/how-do-i-copy-folder-with-files-to-another-folder-in-unix-linux

http://stackoverflow.com/questions/9622883/recursive-copy-of-specific-files-in-unix-linux