GNU ZIP (“gzip”) is another compressing command tool commonly used in Linux. Just like the bzip2 program it is used to compress files while the “gunzip” is used to decompress files. The file extension of files compressed with gzip end with ‘.gz’. for example;
The end product (the compressed file) would become memo.txt.gz
You can compress multiple files with gzip by just separating the different file names of the files to be compressed with a single space;
gzip file1 file2
Both files become file1.gz file2.gz
Decompressing with gunzip is also similar;
gunzip file1.gz file2.gz
Or using the decompress option of the gzip command;
gzip -d file1.gz file2.gz
Gunzip take the list of files on its command line and replace each file whose name ends with .gz, -gz, .z, -z, with an uncompressed file without the original extension.
To get a list of compressed file(s), the –l [list] option is used with the gunzip command like this;
gunzip –l stm.png.gz
The output from the above command would contain the following information;
Compressed: size of the compressed file
Uncompressed: size of the uncompressed file
Ratio: ratio of compression (0.0% if unknown)
Uncompressed_name: the name of the uncompressed file.
You can also use gzip and gunzip like this;
gzip –c originalFile
To produce a newFile.gz file
gunzip –c newFile.gz
You will get oringinalFile, as before. And the ‘–c’ option writes to standard output and keeps the original file unchanged.