tar

From NetBSD Wiki

Jump to: navigation, search

The tar(1) tape archiver

To create an archive :

$ tar cf plop.tar /plop

To test an archive file :

$ tar tf plop.tar
  plop
  plop/plop

To extract an archive file :

$ tar xf plop.tar
  

To get a verbose output, use the -v option :

$ tar xvf plop.tar
  x plop
  x plop.tar

To extract to another destination :

$ tar xf plop.tar -C /test 

To extract a part of an archive :

$ tar xzvf HandBrake-0.6.2-src.tar.gz HandBrake-0.6.2/test
x HandBrake-0.6.2/test/
x HandBrake-0.6.2/test/test.c

The z option, used in this example, indicates that tar should use gzip to decompress the archive before extracting. The same option can also be used when creating an archive, specifying that the resulting tar file should be compressed.

$ tar cfz src.tar.gz src/

The j and Z options works like the z option, except, they use bzip2 and compress.

$ tar cfj src.tar.bz2 src/
$ tar cfZ src.tar.Z src/

See also

Retrieved from "http://wiki.netbsd.se/tar"
Personal tools