Monday, October 26, 2009

Howto Unzip .gz, tar.gz, .zip Files in Linux, Quick Examples

$ gzip myfile.txt
____zip (creates myfile.gz, deletes myfile.txt)
$ gzip -r mydir
___ zip several files--doesn't package! (creates .gz versions of each file in mydir. Not gzip and gunzip don't group several files together into one file, for that you need tar)
$ gunzip myfile.gz
___ unzip (creates myfile.txt, deletes myfile.gz)

$ tar -xzfv foo.tar.gz
___ unzip and extract (note: tar by itself just groups / archives files, it doesn't compress. Using the z option causes it to use gzip/gunzip to also compress / uncompress files.)
___ x/c: extract, use c to create an archive
___ z: use gzip/gunzip to also compress (you end up with .gz files)
___ f: operate on a file and not typed input
___ v: print out files it's operating on verbosely
$ tar -cf foo.tar mydir.tar mydir/
___ archive folder (add option z to also compress)

$ zip -r test.zip mydir
____zip (replace mydir with * to zip up everything in the cur dir)
$ unzip test.zip
____unzip

No comments: