manpagez: man pages & more
info tar
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.6 Notable tar Usages

(This message will disappear, once this node revised.)

You can easily use archive files to transport a group of files from one system to another: put all relevant files into an archive on one computer system, transfer the archive to another system, and extract the contents there. The basic transfer medium might be magnetic tape, Internet FTP, or even electronic mail (though you must encode the archive with uuencode in order to transport it properly by mail). Both machines do not have to use the same operating system, as long as they both support the tar program.

For example, here is how you might copy a directory’s contents from one disk to another, while preserving the dates, modes, owners and link-structure of all the files therein. In this case, the transfer medium is a pipe:

$ (cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)

You can avoid subshells by using ‘-C’ option:

$ tar -C sourcedir -cf - . | tar -C targetdir -xf -

The command also works using long option forms:

$ (cd sourcedir; tar --create --file=- . ) \
       | (cd targetdir; tar --extract --file=-)

or

$ tar --directory sourcedir --create --file=- . \
       | tar --directory targetdir --extract --file=-

This is one of the easiest methods to transfer a tar archive.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on November 1, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.