Recursive file copy - with out the tree


Suppose you have  directory tree o and you want to copy all the files in that directory tree into another, how do you do that? well there are lots of solutions, including 'cp -a' and 'rsync -a'. But what if you want to copy only the files, you don't want the directories? In other words you want to collapse (squash) the directory structure. That's also easy enough. As an example suppose you wanted to copy all the downloaded rpm files into a single location so that you can set up a local repository or burn it to a DVD.

find /var/cache/yum/ -name  '*rpm' -exec cp '{}' '.' ';'

This command copy all the contents of all the sub folders in the source into one single target directory.
comments powered by Disqus