温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

文件目录的解压缩命令

发布时间:2020-07-17 13:34:01 来源:网络 阅读:167 作者:mb5a9ffa90ab728 栏目:系统运维

文件目录压缩/解压缩

文件压缩/解压缩 ----- 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
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI