压缩和解压缩

压缩和解压缩

压缩工具:gzip、bzip2、rar、7zip、libzip2、xz

zip和unzip

1.1:zip 压缩文件名 (text.zip)要被压缩的名字

[root@localhost test]# zip test1.zip test1.txt
adding: test1.txt (stored 0%)
[root@localhost test]# ls test1*
test1.txt test1.zip

1.2:把test2添加到test1.zip中

[root@localhost test]# zip -m test1.zip text2.txt

1.3: 把test2从test1.zip中删除

[root@localhost test]# zip -d test1.zip test2.txt

1.4:除了test10以外将所有.txt/压缩

[root@localhost test]# zip test.zip*.txt -x test10.txt

1.5:zip -r 递归压缩(将当前目录连同目录下文件一起压缩)

[root@localhost test]# zip -r dir1.zip dir1/
adding: dir1/ (stored 0%)
adding: dir1/fstab (deflated 50%)
[root@localhost test]# ls dir*
dir1.zip
dir1:
fstab

2.1:unzip解压文件

[root@localhost test]# unzip test1.zip

2.2:将压缩文件在指定目录下解压缩

[root@localhost test]# unzip test1.zip -d dir1
Archive: test1.zip
extracting: dir1/test1.txt
extracting: dir1/test2.txt

2.3:unzip -v test1.zip 不解压,查看压缩内容

[root@localhost test]# unzip -v test1.zip
在这里插入图片描述

gzip和gunzip

1.1:gzip 被压缩文件名,压缩后,源文件不保留

[root@localhost test]# gzip test1.txt
[root@localhost test]# ls test1*
test1.txt.gz test1.zip

1.2:gzip -r 目录 压缩了目录下的所有内容。

[root@localhost test]# gzip -r dir1/

1.3:gzip -c test2.txt > test2.txt.gz 压缩,保留源文件

[root@localhost test]# gzip -c test2.txt > test2.txt.gz
[root@localhost test]# ls test2*
test2.txt test2.txt.gz

2.1:gunzip .解压文件至原路径

[root@localhost test]# gunzip test1.txt.gz
[root@localhost test]# ls test1*
test1.txt test1.zip

2.2: 解压至指定路径

[root@localhost test]# gunzip -c test2.txt.gz > /tmp/test.txt

2.3:.解压目录下的压缩文件

[root@localhost test]# gunzip -r dir1
[root@localhost test]# ls dir1
fstab test1.txt test2.txt

gunzip 和 gzip  -d 等价

不解压查看

[root@localhost test1]# zless test2.txt.gz

bzip2和bunzip2

1.1:bzip2 被压缩的文件名 ,压缩后,源文件不保留

[root@localhost test]# bzip2 test1.txt
[root@localhost test]# ls test1*
test1.txt.bz2 test1.zip

1.2:压缩,保留源文件

[root@localhost test]# bzip2 -c test2.txt > test2.txt.bz2
[root@localhost test]# ls test2*
test2.txt test2.txt.bz2 test2.txt.gz

2.1:将test2.txt.bz2解压缩

[root@localhost test]# bunzip2 test2.txt.bz2

bunzip2 和 bzip  -d 等价

不解压查看

[root@localhost test1]# bzcat test5.txt.bz2

xz和unzx

1.1:xz 被压缩的文件名,压缩后,源文件不保留

[root@localhost test]# xz test2.txt
[root@localhost test]# ls test2*
test2.txt.bz2 test2.txt.gz test2.txt.xz

1.2:查看压缩后的文件内容

[root@localhost test]# xzcat test2.txt.xz

1.3:压缩目录下文件

[root@localhost test]# xz dir1/*
[root@localhost test]# ls dir1
fstab.xz test1.txt.xz test2.txt.xz

2.1:解压缩

[root@localhost test]# unxz test1.txt.xz

2.2:解压目录下文件

[root@localhost test]# xz -d dir1/*
[root@localhost test]# ls dir1
fstab test1.txt test2.txt

xz  -d 等价于 unxz
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值