Bootstrap FreeKB - Linux Commands - gunzip (unzip a gzip archive)
Linux Commands - gunzip (unzip a gzip archive)

Updated:   |  Linux Commands articles

The gunzip command can be used to uuncompress a gzip compressed file. Let's take an example where the /home/john.doe directory contains a gzip compressed file.

[john.doe@server1 ~]# ls -l /home/john.doe
-rw-r--r-- john.doe john.doe 12345 Jan 01 :17:16 example.file.gz

 

The gunzip command can be used to decompress example.file.gz.

[john.doe@server1 ~]# gunzip /home/john.doe/example.file.gz

 


Decompress numerous files in a directory

The -r or --recursive option can be used to uncompress every gzip compressed file at or below a directory. In this example, every file at and below /home/john.doe will be decompressed.

[john.doe@server1 ~]# gunzip -r /home/john.doe

 

 


Display the contents of the compressed file

The -c, --stdout, or --to-stdout options can be used to view the contents of a gzip compressed file. In this example, the contents of example.file.gz are displayed.

[john.doe@server1 ~]# gunzip -c /home/john.doe/example.file.gz
Hello World

 


Statistics

The -l or --list option can be used to view statistics of a compressed gzip file. The -l option will display the size of the uncompressed file, the size of the compressed file, the compression percentage, and the name of the uncompressed file.

[john.doe@server1 ~]# gunzip -l /home/john.doe/example.file.gz
compressed  uncompressed  ratio  uncompressed_name
        52           672  96.9%       example.file

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a2cc48 in the box below so that we can be sure you are a human.