Friday, November 18, 2005

Copy a Directory using tar

Another way to copy directory hierarchies is to use the tar utility, described in section 6.3.7. The following sequence of commands copies a structure from the source directory to the destination directory:

% cd source_dir; tar cf - . | (cd destination_dir; tar xfBp -)

The "-" is used for the name of the tar file (argument to the f option) so that tar writes to the standard output or reads from the standard input, as appropriate.

0 comments: