Using tar to zip/unzip files

Submitted by Ki Kim on Wed, 06/13/2012 - 9:28am
Ki Kim's picture

Extract files from a tar file (see x in the arguments).

$ tar -xvf foo.tar

Extract gz compressed tarball.

$ tar -xvzf foo.tar.gz
$ tar -xvzf foo.tgz

tar seems to work without z as well.

$ tar -xvf foo.tar.gz

Extract one file.

$ tar -xvzf foo.tgz onefile.php

Creat a tar file and zip it (see c in the arguments).
(tar allows arguments with no dash for historical reason)

$ tar cvzf foo.tgz *.php *.txt
$ tar cvzf foo.tgz mydirectory
Category: 

Post new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.