Home > Operation and Maintenance > Linux Operation and Maintenance > How to use gzip compression command

How to use gzip compression command

王林
Release: 2020-10-26 15:32:34
Original
15578 people have browsed it

How to use the gzip compression command: [gzip [option] source file], such as [gzip install.log]. gzip is a command commonly used in Linux systems to compress and decompress files.

How to use gzip compression command

gzip is a command often used to compress and decompress files in Linux systems. The extension of the new file compressed by this command is usually marked as ".gz".

Video tutorial recommendation: linux video tutorial

The basic format of the gzip command is as follows:

[root@localhost ~]# gzip [选项] 源文件
Copy after login

Basic compression

The gzip compression command is very simple. You don't even need to specify the compressed package name after compression, just the source file name. Let’s try:

[root@localhost ~]# gzip install.log
#压缩instal.log 文件
[root@localhost ~]# ls
anaconda-ks.cfg install.log.gz install.log.syslog
#压缩文件生成,但是源文件也消失了
Copy after login

Preserve source file compression

When compressing a file using the gzip command, the source file disappears, resulting in a compressed file. At this time, some people will have obsessive-compulsive disorder and ask the author: Can you prevent the source file from disappearing when compressing the file? Okay, it's possible, but it's very awkward.

[root@localhost ~]# gzip -c anaconda-ks.cfg >anaconda-ks.cfg.gz
#使用-c选项,但是不让压缩数据输出到屏幕上,而是重定向到压缩文件中,这样可以缩文件的同时不删除源文件
[root@localhost ~]# ls
anaconda-ks.cfg anaconda-ks.cfg.gz install.log.gz install.log.syslog
#可以看到压缩文件和源文件都存在
Copy after login

Related recommendations: linux tutorial

The above is the detailed content of How to use gzip compression command. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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