Compression and decompression of Linux commands

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.