Linux压缩实用程序

1。 压缩

以下是可用于压缩文件的主要实用程序

归档文件的格式:zip <文件名> <源文件>

[[email protected] zip_test]# zip test.zip mytest1.txt mytest2.txt mytest3.txt
adding: mytest1.txt (deflated 92%)
adding: mytest2.txt (deflated 92%)
adding: mytest3.txt (deflated 92%)
[[email protected] zip_test]# ll
total 16
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 511 Mar 19 12:19 test.zip
[[email protected] zip_test]#

解压缩文件的格式:unzip <文件名> .zip

[[email protected] zip_test]# ll
total 16
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 511 Mar 19 12:19 test.zip
[[email protected] zip_test]# rm -f *.txt

注意:要删除文本文件以更好地理解该主题,请不要在您的环境中运行此命令。

[[email protected] zip_test]# ll
total 4
-rw-r–r–. 1 root root 511 Mar 19 12:10 test.zip
[[email protected] zip_test]# unzip test.zip
Archive: test.zip
inflating: mytest1.txt
inflating: mytest2.txt
inflating: mytest3.txt
[[email protected] zip_test]# ll
total 16
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 511 Mar 19 12:19 test.zip
[[email protected] zip_test]#

2。 gzip

存档文件的格式: gzip

[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[[email protected] zip_test]# gzip mytest1.txt mytest2.txt mytest3.txt
[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest1.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest2.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:13 mytest3.txt.gz
[[email protected] zip_test]#

GUNziping文件的格式: 压缩文件.gz

[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest1.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest2.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:13 mytest3.txt.gz
[[email protected] zip_test]# gunzip mytest1.txt.gz
[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest2.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:13 mytest3.txt.gz
[[email protected] zip_test]# gunzip mytest2.txt.gz mytest3.txt.gz
[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[[email protected] zip_test]#

3。 bzip2

使用以下格式归档文件的格式:bzip2

[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[[email protected] zip_test]# bzip2 mytest1.txt mytest2.txt mytest3.txt
[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest1.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest2.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:13 mytest3.txt.bz2

BUNzip文件格式:bunzip2 .bz2

[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest1.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest2.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:13 mytest3.txt.bz2
[[email protected] zip_test]# bunzip2 mytest1.txt.bz2
[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest2.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:13 mytest3.txt.bz2
[[email protected] zip_test]# bunzip2 mytest2.txt.bz2 mytest3.txt.bz2
[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[[email protected] zip_test]#

4.团队 柏油:

用于从文件中保留tar的格式:tar -cvf .tar

[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[[email protected] zip_test]# tar -cvf test.tar mytest1.txt mytest2.txt mytest3.txt
mytest1.txt
mytest2.txt
mytest3.txt
[[email protected] zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[[email protected] zip_test]#

解压缩文件的格式:tar -xvf

[[email protected] zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[[email protected] zip_test]# rm -f *.txt

注意:为了更好地理解该主题,请删除txt文件,请不要在您的环境中运行此命令。

[[email protected] zip_test]# ll
total 12
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[[email protected] zip_test]#
[[email protected] zip_test]# tar -xvf test.tar
mytest1.txt
mytest2.txt
mytest3.txt
[[email protected] zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[[email protected] zip_test]#

[[email protected] zip_test]# tar -tvf test.tar
-rw-r–r– root/root 221 2015-06-14 09:12 mytest1.txt
-rw-r–r– root/root 221 2015-06-14 09:12 mytest2.txt
-rw-r–r– root/root 221 2015-06-14 09:13 mytest3.txt
[[email protected] zip_test]#

Sidebar