CentOS Fedora 利用p7zip压缩、解压文件

安装p7zip

# yum install -y p7zip p7zip-plugins

利用7z指令压缩文件,压缩dump.sql文件为例:

$ ll
total 1320800
-rw-rw-r-- 1 yeqiang yeqiang 1352498605 Jul 18 20:18 dump.sql
[yeqiang@localhost test]$ 7z a dump.sql.7z dump.sql 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz (906E9),ASM,AES-NI)

Scanning the drive:
1 file, 1352498605 bytes (1290 MiB)

Creating archive: dump.sql.7z

Items to compress: 1

                 
Files read from disk: 1
Archive size: 96276207 bytes (92 MiB)
Everything is Ok
[yeqiang@localhost test]$ ll -h
total 1.5G
-rw-rw-r-- 1 yeqiang yeqiang 1.3G Jul 18 20:18 dump.sql
-rw-rw-r-- 1 yeqiang yeqiang  92M Jul 18 20:20 dump.sql.7z
-rw-rw-r-- 1 yeqiang yeqiang 128M Jul 18 20:21 dump.sql.tar.gz

其中dump.sql.tar.gz使用tar 指令压缩出来的包,参考指令如下

$ tar -zcvf dump.sql.tar.gz dump.sql
dump.sql

对比两种压缩程序,p7zip压缩出来的文件只有tar gzip压缩出来文件体积的70%左右。

 

p7zip 解压

[yeqiang@localhost test]$ 7z x dump.sql.7z 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz (906E9),ASM,AES-NI)

Scanning the drive for archives:
1 file, 96276207 bytes (92 MiB)

Extracting archive: dump.sql.7z
--
Path = dump.sql.7z
Type = 7z
Physical Size = 96276207
Headers Size = 122
Method = LZMA2:24
Solid = -
Blocks = 1

    
Would you like to replace the existing file:
  Path:     ./dump.sql
  Size:     1352498605 bytes (1290 MiB)
  Modified: 2018-07-18 20:18:27
with the file from archive:
  Path:     dump.sql
  Size:     1352498605 bytes (1290 MiB)
  Modified: 2018-07-18 20:18:27
? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? u

Everything is Ok

Size:       1352498605
Compressed: 96276207
[yeqiang@localhost test]$ ll -h
total 2.8G
-rw-rw-r-- 1 yeqiang yeqiang 1.3G Jul 18 20:18 dump_1.sql
-rw-rw-r-- 1 yeqiang yeqiang 1.3G Jul 18 20:18 dump.sql
-rw-rw-r-- 1 yeqiang yeqiang  92M Jul 18 20:20 dump.sql.7z
-rw-rw-r-- 1 yeqiang yeqiang 145M Jul 18 20:21 dump.sql.tar.gz

 

你可能感兴趣的:(centos,linux)