Linux gunzip command
The Linux gunzip command is used to decompress files.
gunzip is a widely used decompression program. It is used to uncompress files compressed by gzip. These compressed files have a preset final extension of.gz. In fact, gunzip is a hard link to gzip, so whether compressing or decompressing, it 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 decompressed file with the same name already exists.-h: Display help information.-k: Keep the original compressed file. The decompressed file will be kept in the same directory without deleting the original file.-l: Display detailed information about the compressed file, including file size before and after compression, compression ratio, etc.-n: Do not overwrite existing decompressed files. If a file with the same name already exists, no decompression operation will be performed.-q: Silent mode. Do not display decompression progress and error messages.-r: Recursively decompress all files in the specified directory.-t: Test the integrity of the compressed file without actually performing decompression.-v: Display detailed decompression information, including the decompressed file name, compression ratio, etc.--help: Display help information.--version: Displaygunzipcommand version information.
Examples
1. Decompress a file:
gunzip example.txt.gz
This will decompress the file named example.txt.gz and generate a decompressed file named example.txt.
2. Decompress a file and keep the original file:
gunzip -k example.txt.gz
This will decompress the example.txt.gz file and generate a decompressed file named example.txt, while keeping the original example.txt.gz file.
Decompress a file and output the content to standard output:
gunzip -c example.txt.gz
This will decompress the example.txt.gz file and output the decompressed content to standard output instead of generating a decompressed file.
Recursively decompress all files in a directory:
gunzip -r directory
This will recursively decompress all files compressed in gzip format under the specified directory.
Note that the gunzip command can only decompress files in gzip format and cannot be used to decompress other compression formats such as ZIP, RAR, etc. To decompress files in other formats, you can use corresponding tools, for example, the unzip command for decompressing ZIP files.
Other extensions
Linux Command Reference