首页 > 其他 > 详细

文件目录的解压缩命令

时间:2019-09-10 00:14:37      阅读:107      评论:0      收藏:0      [点我收藏+]
文件目录压缩/解压缩

文件压缩/解压缩 ----- gzip/bzip/xz

1)gzip *.gz

压缩:

[root@localhost ~]# gzip /bbq/1.txt
[root@localhost ~]# ls /bbq/
1.txt.gz

[root@localhost ~]# file /bbq/1.txt.gz
/bbq/1.txt.gz: gzip compressed data, was "1.txt", from Unix, last modified: Sat Sep 7 05:33:50 2019

解压缩:

[root@localhost ~]# gzip -d /bbq/1.txt
[root@localhost ~]# ls /bbq/
1.txt

2) bzip2 *.bz2

[root@localhost ~]# bzip2 /bbq/1.txt
[root@localhost ~]# file /bbq/1.txt.bz2
/bbq/1.txt.bz2: bzip2 compressed data, block size = 900k

[root@localhost ~]# bzip2 -d /bbq/1.txt.bz2
[root@localhost ~]# ls /bbq/
1.txt

3)xz *.xz

[root@localhost ~]# xz /bbq/1.txt
[root@localhost ~]# file /bbq/1.txt.xz
/bbq/1.txt.xz: XZ compressed data

[root@localhost ~]# xz -d /bbq/1.txt.xz
[root@localhost ~]# ls /bbq/
1.txt

创建打包文件 ---tar

1)创建打包文件 *.tar

tar cf 打包文件名称 源文件

      c : create创建
      f : file文件

[root@localhost bbq]# tar cf 1.tar 1.txt
[root@localhost bbq]# file 1.tar
1.tar: POSIX tar archive (GNU)

2)解包

#tar xf 打包文件名称 [-C 目录名称]

[root@localhost bbq]# tar xf 1.tar

[root@localhost bbq]# tar xf 1.tar -C /kvm/

3)查看包中的文件

[root@localhost bbq]# tar tvf 1.tar
-rw-r--r-- root/root 0 2019-09-07 05:33 1.txt

调用gzip事先压缩/解压缩

#tar czf 打包文件名称 源文件

     z:   调用gzip

[root@localhost bbq]# tar czf /kvm/1.tar.gz /bbq/

[root@localhost bbq]# ls /kvm
1.tar.gz

解压缩

[root@localhost ~]# tar zxf /kvm/1.tar.gz -C /tmp/

调用bzip2实现压缩/解压缩

#tar cjf 打包文件名称 目录名称

     j : 调用bzip2

[root@localhost ~]# tar cjf /kvm/1.tar.bz2 /kvm/

解压缩
[root@localhost ~]# tar xjf /kvm/1.tar.bz2 -C /tmp/

调用xz实现压缩/解压缩

tar cJf 打包文件名称 目录名称

      J:  调用xz

文件目录的解压缩命令

原文:https://blog.51cto.com/13632438/2436689

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!