Home  >  Article  >  Operation and Maintenance  >  How to decompress gz format files in linux

How to decompress gz format files in linux

PHPz
PHPzforward
2023-05-17 15:32:1010116browse

For gz format files, you can use the "gunzip" command or the "gzip -d" command to decompress in Linux. The gunzip command is used to decompress files compressed by gzip, that is, decompress files with the extension ".gz", the syntax is "gunzip [options] file..."; for decompressing files compressed by gzip, you can also use gzip itself , that is, "gzip -d compressed package".

The gunzip command in Linux can be used to decompress .gz compressed files. In fact, gunzip is a hard connection to gzip, so both compression and decompression can be completed separately through the gzip command. .

Linux gunzip command: Decompress files or directories

The widely used decompression command gunzip can be used to decompress gzip compressed files with a .gz extension.

To decompress files compressed by gzip, you can also use gzip itself, that is, gzip -d compressed package.

The basic format of the gunzip command is:

gunzip [options] file...
Parameters Description
options Parameters used by the gunzip command.
file The name of the file to be decompressed.

Commonly used parameters of gunzip command

Parameter Description
-a, --ascii Use ASCII text mode.
-c, --stdout, --to-stdout Output the decompressed file to the standard output device.
-f, --force Forcibly decompress the compressed file, regardless of whether the file name or hard link exists and whether the file is a symbolic link.
-l, --list List related information of compressed files.
-L, --license Display version and copyright information.
-n, --no-name When compressing a file, the original file name and timestamp will not be saved.
-N, --name When compressing a file, save the original file name and timestamp.
-q, --quiet Do not display warning messages.
-r, --recursive Recursive processing, all files and subdirectories in the specified directory will be processed together.
-t, --test Test whether the compressed file is correct.
-v, --verbose Display the instruction execution process.

Example 1】Decompress the file directly.

[root@localhost ~]# gunzip install.log.gz

Naturally, "gunzip -r" will still only decompress the files in the directory, but not unpack them. To decompress the ".gz" format, you can also use the "gzip -d" command, for example:

[root@localhost ~]# gzip -d anaconda-ks.cfg.gz

[Example 2] To decompress the contents of the directory, you need to use the "-r" option. For example:

[root@localhost ~]# gunzip -r test/

Note that if we are compressing a plain text file, you can directly use the zcat command to view the contents of the text file without decompressing it. For example:

[root@localhost ~]# zcat anaconda-ks.cfg.gz

The above is the detailed content of How to decompress gz format files in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete