1 gzip
[Email protected] ~]# gzip a.sh #压缩后文件后缀为. gz
[Email protected] ~]# gzip-d a.sh.gz #解压gz文件
[Email protected] ~]# zcat a.sh.gz #查看压缩文件
2 bZIP
[Email protected] ~]# bzip2 a.sh #压缩后文件后缀为bz2
[Email protected] ~]# bzip2 a.sh.bz2-d #解压文件
[Email protected] ~]# Bzcat a.sh.bz2 #查看压缩文件
Note: gzip and bzip2 currently do not support the compression of the directory
3 Zip: Supports compression of the directory
Option:-R recursive compression
-D Specify Unzip directory
-O Overwrite the original file without prompting
[Email protected]/]# zip-r root.zip/root/* #压缩
[Email protected] ~]# unzip-o-d/c root.zip #解压到根下的C目录下
4 Tar: Package and unpack files
Usage: tar [main option + Secondary options] path ... #主选项是必须的, the secondary option can be selected
Main option:-C to create a packaged file
-X Release packaged files
-T lists the contents of a packaged document
-R append file to package file
--delete deleting files from a packaged file
Secondary option:-c Specifies the decompression path
-f Specifies the name of the package
-Z Compression after packaging with gzip format
-j compressed by bzip2 format after packaging
-P preserves the properties of the original file, such as file permissions
[Email protected]/]# TAR-CZF etc.tar.gz/etc/#打包并压缩目录
[Email protected]/]# TAR-TF etc.tar.gz #列出打包文档的内容
[Email protected]/]# TAR-XZF etc.tar.gz-c/C #把文件解压到C目录下
[Email protected]/]# TAR-RF a.tar/root/a.txt #把文件追加到归档包中
[[Email protected]/]# tar--delete root/a.txt-f/a.tar# remove a.txt from packaged files
This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1916770
Compression and decompression of Linux commands