Site Feed

Thursday, May 29, 2008

How to Copy Directories Using Tar

To copy all files from /usr/local/source to /usr/local/destination, there are several options.

Tar
cd /usr/local/source
tar -cvf - . | (cd /usr/local/destination; tar -xvf -)

This method uses tar, but rather than create a file, it writes to a stream "-" in std output. The stream is piped to another tar command, after changing to another directory.

cp -a

cp -a /usr/local/src/* /usr/local/destination

Other options:

cpio

dd

No comments: