In continuation of our series of Linux tutorials,I am here presenting the gzip and gunzip commands in Linux
gzip and gunzip command
gzip: The gzip utility will attempt to reduce the size of the named files. The file will be replaced by one with the extension .gz, while keeping the same ownership modes, change times and modification times.
gunzip: The gunzip utility will restore files to their original state after they have been compressed using the gzip utility.
$ls alert_CHECK.log $gzip alert_CHECK.log $ ls alert_CHECK.log.gz $ls alert_CHECK.log.gz $gunzip alert_CHECK.log.gz $ ls alert_CHECK.log
The gzip command can be used with the tar command also to gzip the tar files. An example is shown below
tar gzip command
tar -cvf - file1 file2 | gzip > file.tar.gz
A similar gunzip command can be used with the tar command also to unzip the tar files. An example is shown below
tar gunzip command
gunzip -c file.tar.gz|tar -xvf -
Difference between gzip and compress
Both the utility compress and gzip compress the file i.e serve the same purpose
(1) In general Compress will run faster and use less memory, but gzip will generally reach significantly higher levels of compression.
(2) Compress is an old algorithm while gzip is the new one