Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Gzip to compress and extract files in Linux

Shulou Source: shulou.com Published: 2022-06-01 08:05:02 10月29日 Update

This article mainly introduces "how to use Gzip to compress and decompress files in Linux". In daily operation, I believe many people have doubts about how to use Gzip to compress and decompress files in Linux. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to answer your doubts about "how to use Gzip to compress and decompress files in Linux"! Next, please follow the small series to learn together!

Gzip stands for GNU zip, which is a compression application widely used in Linux operating systems. The files compressed by Gzip have the suffix '*. gz'.

The basic usage is as follows:

a) Compressed files

The code is as follows:

gzip file(s)

Each file will be compressed separately.

compressed file

Usually after compression is complete, it deletes the original file. We can use the-c option to keep the original file.

The code is as follows:

gzip -c file > file.gz

Keep the original file after compression

We can also compress a group of files into a single file

The code is as follows:

cat file1 file2 file3 | gzip > archieve.gz

compress a set of files

b) Check compression ratio

The compression ratio of the compressed file can be checked using the '-l' option.

The code is as follows:

gzip -l archieve.gz

Check compression ratio

c) Extract files

Gunzip is used to extract files, where the original (compressed) files are also deleted after extraction. Use the-c option to preserve the original file.

The code is as follows:

gunzip -c archieve.gz

extract the files

Gzip plus the '-d' option has the same effect as gunzip on compressed files.

More details can be found on the gzip homepage.

At this point, on "how to use Gzip in Linux to compress and decompress files" learning is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Files code learning more help check original practical next operating system home page suffix effects articles methods theories knowledge articles systems details Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Docker MariaDB macOS