Skip to main content

Posts

Showing posts from November 13, 2005

Notable tar Usages

From the gnu.org site: 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 , which is one a Unix redirection mechanism: $ cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -) Here's a sample: sudo tar cvzf /media/MyBook500-ext3/Volume/home-2007-10-20.tgz /home/

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.