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

How to decompress gz format files in linux

PHPz
Release: 2023-05-17 15:32:10
forward
10140 people have browsed it

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...
Copy after login
ParametersDescription
options Parameters used by the gunzip command.
fileThe name of the file to be decompressed.

Commonly used parameters of gunzip command

ParameterDescription
-a, --asciiUse ASCII text mode.
-c, --stdout, --to-stdoutOutput the decompressed file to the standard output device.
-f, --forceForcibly decompress the compressed file, regardless of whether the file name or hard link exists and whether the file is a symbolic link.
-l, --listList related information of compressed files.
-L, --licenseDisplay version and copyright information.
-n, --no-nameWhen compressing a file, the original file name and timestamp will not be saved.
-N, --nameWhen compressing a file, save the original file name and timestamp.
-q, --quietDo not display warning messages.
-r, --recursiveRecursive processing, all files and subdirectories in the specified directory will be processed together.
-t, --testTest whether the compressed file is correct.
-v, --verboseDisplay the instruction execution process.

Example 1】Decompress the file directly.

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

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
Copy after login

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

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

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template