Using Gunzip command-line tool you can decompressing Gzip files. Gzip is the popular compression algorithms to reduce the size of a file and keep the original file mode, ownership, and timestamp. In this tutorial, we will show you how to use the gunzip
command.
Decompressing Files with gunzip
Below is the basic syntax for the gunzip command:
gunzip [OPTION]... [FILE]...
The gunzip
is a bash script wrapper to the gzip -d command in most Linux distributions, such as Ubuntu, CentOS, and Debian.
All gzip
command line options are applicable gunzip
. You can decompress a .gz
file with gunzip
by passing compressed file name:
gunzip filename.gz
It will restore the compressed file to its original name, owner, mode and timestamp.
After decompress, by default, gunzip
will remove the compressed file. You can use the -k
option to keep the file:
gunzip -k filename.gz
Use the -c
option to write the output on the terminal.
gunzip -c filename.gz > /directory/path/filename
You can pass the multiple files as arguments with the gunzip
command:
gunzip file1.gz file2.gz file3.gz
To recursively decompresses all files in a given directory, use the -r
option:
gunzip -r directory
List the Compressed File Contents
Use the -l
option with gunzip
, to show information about the given compressed files:
gunzip -l filename.gz
In output, it will show the uncompressed file name, the compressed and uncompressed size, and the compression ratio:
compressed uncompressed ratio uncompressed_name
246 282 8.2% filename
For more verbose output, use the -v
option:
gunzip -lv filename
method crc date time compressed uncompressed ratio uncompressed_name
defla 8afa3fs5 Oct 24 11:40 246 282 8.2% filename
Conclusion
The gunzip command is used to decompress .gz
files. To learn more about the gunzip
command, visit the Gnu gzip documentation page.
If you have any questions, please leave a comment below.