Linux gunzip Command
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 [选项] 压缩文件
-c: Output the decompressed file content to standard output (instead of writing to a file).-d: Decompress the file. This is the default behavior and can be omitted.-f: Force decompression, even if a file with the same name already exists.-h: Display help information.-k: Keep the original compressed file. The decompressed file is kept in the same directory, and the original file is not deleted.-l: Display detailed information about the compressed file, including file size before and after compression, compression ratio, and so on.-n: Do not overwrite existing decompressed files. If a file with the same name already exists, no decompression is performed.-q: Silent mode; do not show decompression progress or error messages.-r: Recursively decompress all files in the specified directory.-t: Test the integrity of the compressed file without actually decompressing it.-v: Display verbose decompression information, including the names of decompressed files, compression ratios, and so on.--help: Display help information.--version: Displaygunzipthe version information of the command.
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