Open In App

gunzip command in Linux with examples

gunzip command is used to compress or expand a file or a list of files in Linux. It accepts all the files having extension as .gz, .z, _z, -gz, -z , .Z, .taz or.tgz and replace the compressed file with the original file by default. The files after uncompression retain its actual extension.

Syntax:



gunzip [Option] [archive name/file name]

Example 1: The argument that is passed here is: geeksforgeeks.txt which is a compressed text file.

Input:



Output:

geeksforgeeks.txt.gz

Example 2: The argument that is passed here is: geeksforgeeks.txt.gz which is a compressed file.

Input:

Output:

geeksforgeeks.txt

If a file is compressed using gzip command, a suffix i.e. .gz will be added to the file name after compression. Hence while uncompressing this file we can either use the original file name as shown in Example 1 or the filename with the suffix .gz as shown in Example 2 as an argument.

Example 3: In order to uncompress multiple files using the gunzip command, we can pass multiple file names as an argument as shown in the below example:

Syntax:

gunzip [file1] [file2] [file3]...

Input:

Output:

geeksforgeeks.txt, gfg.txt

Options:

Article Tags :