2017-11-9 文档的压缩与打包

1 压缩打包介绍

linux常见打包格式   .zip  .gz  .bz2  .xz  .tar.gz   .tar.bz2   .tar.xz
   

2 gzip 压缩工具---不支持压缩目录的

语法: gzip [-d#] filename 其中#范围1-9,默认6

[root@node69 ~]# cd /tmp/
[root@node69 tmp]# mkdir d6z
[root@node69 tmp]# cd d6z/
[root@node69 d6z]# find /etc/ -type f -name "*conf" -exec cat {} >>1.txt \;
[root@node69 d6z]# ls
1.txt
[root@node69 d6z]# du -sh 1.txt
636K	1.txt
[root@node69 d6z]# find /etc/ -type f -name "*conf" -exec cat {} >>1.txt \;
[root@node69 d6z]# find /etc/ -type f -name "*conf" -exec cat {} >>1.txt \;
[root@node69 d6z]# du -sh 1.txt
2.6M	1.txt
[root@node69 d6z]# wc -l 1.txt
55383 1.txt
[root@node69 d6z]# gzip 1.txt
[root@node69 d6z]# ls
1.txt.gz
[root@node69 d6z]# du -sh 1.txt.gz 
496K	1.txt.gz
[root@node69 d6z]# gzip -d 1.txt.gz 
[root@node69 d6z]# ls
1.txt
[root@node69 d6z]# du -sh 1.txt 
1.9M	1.txt
gzip -c 文件名 > 另存文件名:表示压缩文件后而不删除源文件,把压缩文件定向到指定目录和名称
[root@node69 d6z]# gzip -c 1.txt > /tmp/1.txt.gz
[root@node69 d6z]# ls
1.txt
[root@node69 d6z]# ls /tmp/1.txt.gz 
/tmp/1.txt.gz
[root@node69 d6z]# file !$
file /tmp/1.txt.gz
/tmp/1.txt.gz: gzip compressed data, was "1.txt", from Unix, last modified: Fri Nov 10 09:23:59 2017
[root@node69 d6z]# gzip -d -c /tmp/1.txt.gz > /tmp/d6z/2.txt
[root@node69 d6z]# ls
1.txt  2.txt
[root@node69 d6z]# wc -l 1.txt 2.txt
  55383 1.txt
  55383 2.txt
 110766 总用量
[root@node69 d6z]# du -sh *.txt
1.9M	1.txt
1.9M	2.txt

bzip2压缩工具--同样也不可以压缩目录:

默认没有安装,需要安装# yum install -y bzip2
[root@node69 d6z]# bzip2 1.txt
[root@node69 d6z]# ls
1.txt.bz2  2.txt
[root@node69 d6z]# du -sh 1.txt.bz2 
360K	1.txt.bz2
[root@node69 d6z]# du -sh 2.txt 
1.9M	2.txt
[root@node69 d6z]# bzip2 -d 1.txt.bz2 
[root@node69 d6z]# bzip2 1.txt
[root@node69 d6z]# bunzip2 1.txt.bz2 
[root@node69 d6z]# ls
1.txt  2.txt

XZ  压缩工具--同样也不可以压缩目录:
[root@node69 d6z]# xz 2.txt
[root@node69 d6z]# du -sh 2.txt.xz 
144K	2.txt.xz
[root@node69 d6z]# xz -d 2.txt.xz 
[root@node69 d6z]# xz 2.txt 
[root@node69 d6z]# unxz 2.txt.xz 
[root@node69 d6z]# ls
1.txt  2.txt









  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值