Linux self-study journey-basic commands (gzip command of compression and decompression commands)

Linux self-study journey-basic commands (used by gzip command)


Preface

1. In the previous section, we talked about the first compression format zip available under Linux. If you haven’t read it yet, click the link below to enter: zip

2. In this section we talk about the second compressed package format gz


Tip: The following is the content of this article

One, gzip command

The gzip command can compress files into a compressed package in gz format.

  • Command name: gzip
  • The full name of the command: gunzip, zcat-compress or expand files
  • Location: /usr/bin/gzip
  • Execution authority: all users
  • Function description: compressed files
命令格式
gzip [选项] 要压缩的文件
常用选项:
-c:压缩后保留源文件(一般不加-c压缩完后会删除源文件,只保留压缩后的文件)
-d:解压缩
-r:压缩目录文件

Example:

压缩:
[root@VM-0-12-centos snlyj]# ls
ll.txt  loli.txt
[root@VM-0-12-centos snlyj]#
[root@VM-0-12-centos snlyj]# gzip loli.txt
[root@VM-0-12-centos snlyj]#
[root@VM-0-12-centos snlyj]# ls
ll.txt  loli.txt.gz
[root@VM-0-12-centos snlyj]#

(直接gzip后面接文件,系统会自动将文件压缩成.gz后缀的压缩包,并删除源文件。)
(压缩目录加-r选项即可,不想删除源文件加-c选项即可。)

Decompression example:

[root@VM-0-12-centos snlyj]# ls
ll.txt  loli.txt.gz
[root@VM-0-12-centos snlyj]#
[root@VM-0-12-centos snlyj]# gzip -d loli.txt.gz
[root@VM-0-12-centos snlyj]#
[root@VM-0-12-centos snlyj]# ls
ll.txt  loli.txt
[root@VM-0-12-centos snlyj]#

(直接加-d选项后面接要解压缩的.gz格式的压缩包即可解压缩)

Two, gunzip command

gzip -d xx can be used to decompress compressed packages in gz format. The gunzip command is the same as the -d option and can also be used to decompress compressed packages in gz format.

  • Command name: gunzip
  • Location: /usr/bin/gunzip
  • Execution authority: all users
  • Function description: decompress files
命令格式:
gunzip 要解压缩的文件

Example:

[root@VM-0-12-centos snlyj]# ls
ll.txt  loli.txt.gz
[root@VM-0-12-centos snlyj]#
[root@VM-0-12-centos snlyj]# gunzip loli.txt.gz
[root@VM-0-12-centos snlyj]#
[root@VM-0-12-centos snlyj]# ls
ll.txt  loli.txt
[root@VM-0-12-centos snlyj]#

(直接gunzip 后面接要解压缩的文件即可解压缩文件)

to sum up

In this section we learned

{

gzip: The compressed file is a gz format compressed package

gunzip: decompress the compressed package in gz format (gzip -d can also decompress the compressed package in gz format when you connect to the file to be decompressed, depending on which one you use)

}

This is Jiehua, see you next time!

Guess you like

Origin blog.csdn.net/qq313088385/article/details/114308987