In Linux, the gunzip
command is used to decompress files that have been compressed using the gzip
command. It is specifically designed to decompress files with the “.gz” extension.
Here’s an overview of how to use the gunzip
command:
- Basic Usage:
To decompress a file usinggunzip
, simply typegunzip
followed by the name of the file you want to decompress. For example:
gunzip file.txt.gz
This command will decompress the file file.txt.gz
and restore it to its original form as file.txt
.
- Decompressing Multiple Files:
You can use thegunzip
command to decompress multiple files by providing the file names as arguments. For example:
gunzip file1.txt.gz file2.txt.gz
This command will decompress both file1.txt.gz
and file2.txt.gz
, restoring them to their original forms.
- Keeping the Compressed File:
By default,gunzip
replaces the compressed file with the decompressed file. If you want to keep the compressed file while creating a decompressed version, you can use the-c
option to send the decompressed output to the standard output and redirect it to a new file. For example:
gunzip -c file.txt.gz > file.txt
This command decompresses file.txt.gz
and creates a decompressed file named file.txt
, while preserving the compressed file.
- Examples:
- Decompressing a file:
gunzip file.txt.gz
This command decompresses the filefile.txt.gz
and restores it to its original form asfile.txt
. - Decompressing multiple files:
gunzip file1.txt.gz file2.txt.gz
This command decompresses bothfile1.txt.gz
andfile2.txt.gz
, restoring them to their original forms. - Decompressing a file and keeping the compressed file:
gunzip -c file.txt.gz > file.txt
This command decompressesfile.txt.gz
and creates a decompressed file namedfile.txt
, while preserving the compressed file.
The gunzip
command is specifically used for decompressing files that have been compressed with gzip
. It restores the compressed files to their original forms.
For more information about the gunzip
command and its options, you can refer to the manual page by typing man gunzip
in your terminal.