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

11 篇文章 0 订阅

安装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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值