Gzip

From Hackepedia
Jump to navigationJump to search

gzip is a compression program. Its compressed programs have a .gz extension often in association with .tar.gz which is a compressed tarball. To decompress one uses gunzip at which the .tar is left to itself. Often one can also call gunzip from tar itself

tar -xvzf file.tar.gz would decompress based on the -z flag.

$ ls -l termcap
-r--r--r--  1 pjp  wheel  732942 May 30 20:13 termcap
$ gzip termcap
$ ls -l termcap.gz
-r--r--r--  1 pjp  wheel  235552 May 30 20:13 termcap.gz
$ gzip termcap.gz
gzip: termcap.gz already has .gz suffix -- unchanged

Notice the compression ratio on a textfile was about 3:1, but you cannot compress a compressed file again.

You can't get good compression out of files that are already compressed, (such as mp3 or jpg files). Here is an example:

francisco$ ls -l good-morning.mp3
-rw-r--r--  1 pjp  pjp  862336 Apr 21  2007 good-morning.mp3
francisco$ gzip good-morning.mp3
francisco$ ls -l good*
-rw-r--r--  1 pjp  pjp  855614 Apr 21  2007 good-morning.mp3.gz

Notice that compression is minimal.