Wednesday, July 27, 2016

Cloning a Directory Tree in Linux/Unix

Here's an old command that clones an entire directory tree in Unix or Linux. So far, the command appears to work on all variants of Unix (HP-UX, Solaris, AIX, RedHat, Ubuntu, CentOS, and Fedora):

    $ cd to_the_directory_to_be_cloned  
    $ find . -depth -print | cpio -pdv destination_directory  

While the above command clones all files, since find(1) offers many options, you can clone selected files. For example, if you wish to clone only java programs, specify the option "-name '*.java'" to do so.

No comments:

Post a Comment