文件目錄的解壓縮命令

文件目錄壓縮/解壓縮

文件壓縮/解壓縮 ----- 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章