Linux gunzip Command
Learn Linux gunzip Command with examples
Published
- Linux gunzip Command
- gunzip command Syntax
- gunzip command Example
- gunzip Command to Decompress Mltiple Files
- gunzip -r Command to Decompress recursively a Directory
- gunzip -k Command to Keep the gz file
- gunzip -l List the Compressed File Content
- gunzip -lv Compressed File Content with verbose output
Linux gunzip Command
In Linux we use “gunzip” command to decompress Gzip files.
gunzip command Syntax
~$ gunzip [OPTION]... [FILE]...
Gzip is one of the most popular compression algorithms that reduce the size of a file and keep the original file mode, ownership, and timestamp.
gunzip is an alternative to gzip -d. So, instead of using gzip -d we can use gunzip. gunzip is a bash script wrapper to the gzip -d command.
gunzip command Example
~$ gunzip filename.gz
# The command will restore the compressed file to its original name, owner, mode and timestamp.
The gunzip command also accept multiple files as arguments:
gunzip Command to Decompress Mltiple Files
~$ gunzip file_1.gz file_2.gz file_3.gz
gunzip -r Command to Decompress recursively a Directory
~$ gunzip -r files/
# To recursively decompresses all files in a given directory, use the -r option. In this it will decompress "files" directory.
gunzip -k Command to Keep the gz file
~$ gunzip -k filename.gz
# gunzip -k will keep the gzip file after decompresses.
gunzip -l List the Compressed File Content
When used with the -l option, gunzip shows information about the given compressed files:
~$ gunzip -l filename.gz
~$ gunzip -lv filename.gz
# The output will include the uncompressed file name, the compressed and uncompressed size, and the compression ratio.
# -v for verbose
output:
compressed uncompressed ratio uncompressed_name
146 141 9.2% filename
gunzip -lv Compressed File Content with verbose output
~$ gunzip -lv filename.gz
# -v for verbose
# The output will include the uncompressed file name, the compressed and uncompressed size, and the compression ratio.
output:
method crc date time compressed uncompressed ratio uncompressed_name
defla 4a4a3fb5 Aug 29 15:40 146 141 9.2% filename
Read more at Gnu gzip documentation page