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

Linux self-study journey-basic commands (bzip2 command)


Preface

1. In the previous section, we talked about the second compressed package format gz. If you haven’t read it, you can click the link below to watch it: gzip command

2. In this section we describe the third compressed package format bz2


Tip: The following is the content of this article

One, bzip2 command

The third compressed package format we are going to talk about is bz2, and the corresponding compression command is bzip2.

  • Command name: bzip2
  • The full name of the command: a block-sorting file compressor
  • Execution authority: all users
  • Location: /usr/bin/bzip2
  • Function description: compressed files
命令格式
bzip2 [选项] 文件路径
常用选项:
-d:解压缩
-k:压缩后保留源文件
-v:显示详细信息

Compression example:

[root@VM-0-12-centos ceshi]# ls
ch
[root@VM-0-12-centos ceshi]#
[root@VM-0-12-centos ceshi]# bzip2 ch
[root@VM-0-12-centos ceshi]#
[root@VM-0-12-centos ceshi]# ls
ch.bz2
[root@VM-0-12-centos ceshi]#

(直接bzip后面接要压缩的文件,就会自动删除源文件,并生成一个源文件的.bz2压缩包)

Decompression example:

[root@localhost ceshi]# ls
ch.bz2
[root@localhost ceshi]#
[root@localhost ceshi]# bzip2 -d ch.bz2
[root@localhost ceshi]#
[root@localhost ceshi]# ls
ch
[root@localhost ceshi]#-d选项即为解压缩.bz2格式的压缩包)

Two, bunzip2 command

Although the bzip2 -d option can be used to decompress, in fact, the compressed package in .bz2 format can also be decompressed with a separate command.

  • Command name: bzip2
  • Location: /usr/bin/bunzip2
  • Execution authority: all users
  • Function description: decompress files
命令格式
bunzip2 文件路径

Example:

[root@VM-0-12-centos ceshi]# ls
ch.bz2
[root@VM-0-12-centos ceshi]# bunzip2 ch.bz2
[root@VM-0-12-centos ceshi]#
[root@VM-0-12-centos ceshi]# ls
ch
[root@VM-0-12-centos ceshi]#

(如上bunzip2后面接要解压缩的.bz2格式的压缩包即可解压)

to sum up

In this section we talked about

{

bzip2: The compressed file is a compressed package in bz2 format.
bunzip2: Decompress the bz2 format compressed package.

}

Guess you like

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