Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux gunzip Command

Linux gunzip Command

Linux Command Reference Linux Command Reference

The Linux gunzip command is used to decompress files.

gunzip is a widely used decompression program for unpacking files compressed by gzip; these compressed files have a default extension of .gz. In fact, gunzip is a hard link to gzip, so both compression and decompression can be done with the gzip command alone.

Syntax

Parameters:

gunzip [选项] 压缩文件

Example

1. Decompress a file:

gunzip example.txt.gz

This will decompress the file named example.txt.gz and produce a decompressed file named example.txt.

2. Decompress a file and keep the original:



gunzip -k example.txt.gz

This will decompress example.txt.gz and produce a decompressed file named example.txt, while keeping the original example.txt.gz file.

Decompress a file and output its content to standard output:



gunzip -c example.txt.gz

This will decompress example.txt.gz and output the decompressed content to standard output instead of creating a decompressed file.

Recursively decompress all files in a directory:



gunzip -r directory

This will recursively decompress all gzip-compressed files under the specified directory directory.

Note that the gunzip command can only decompress files in gzip format and cannot be used to unpack other compression formats such as ZIP, RAR, etc. To decompress other formats, use the appropriate tool; for example, the unzip command is used to decompress ZIP files.

Linux Command Reference Linux Command Reference