Linux gunzip command

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:

  1. Basic Usage:
    To decompress a file using gunzip, simply type gunzip 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.

  1. Decompressing Multiple Files:
    You can use the gunzip 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.

  1. 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.

  1. Examples:
  • Decompressing a file: gunzip file.txt.gz This command decompresses the file file.txt.gz and restores it to its original form as file.txt.
  • Decompressing multiple files: gunzip file1.txt.gz file2.txt.gz This command decompresses both file1.txt.gz and file2.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 decompresses file.txt.gz and creates a decompressed file named file.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.