PDA

View Full Version : gzip a directory into a file



tcma
7th October 2004, 04:59 AM
How to gzip a directory into a file? I get a directory error when gzip found that the directory is a directory, not a file.

I googled for an hour but still don't get the answer.

superbnerd
7th October 2004, 05:14 AM
have you tried right clicking on the file and choose the archive option, assuming you have a gui (gnome or kde or xfce). Or just open the Archive Manager under System Tools.

crackers
7th October 2004, 05:31 AM
GZIP just does compression, not archiving like ZIP does (two very different things). If you want to archive and GZIP the "old-style" *nix way...


tar -cvzf backup.tgz directory

c = create, v = verbose, z = compress with GZIP, f = archive name

This creates a "tarball" of the directory which can be extracted by replacing the "c" in the above command with "x" (for extract) and leaving off the directory name.

For more info, see man tar

superbnerd
7th October 2004, 05:35 AM
Quick question crackers, what is the difference between a *.tgz and a *.tar.gz? Are they both considered a "tarball"?

sej7278
7th October 2004, 05:36 AM
Or...

tar -cjf backup.tar.bz2 directory

...which creates a bzip2 file (smaller than tarball) which can be decompressed using...

tar -xjf backup.tar.bz2


Edit: .tgz is a bit more "Windows" (three letter extension) and some decompressors don't like it.