Compression and decompression of Linux note files gzip, bzip2, XZ, Zip&unzip, tar Pack, tar Pack and compress and use

Source: Internet
Author: User
Tags bz2 gz file disk usage

Compressing file meaning saves network transmission bandwidth and reduces disk usage. But a certain CPU will be used.

1. Gzip

Compression directory is not supported, gzip directly with the file name, when compressed in the current directory, the original file will disappear.

#gzip filename

Specify the compression directory: #gzip-C 123.txt >/tmp/123.txt.gz to compress the current directory 123.txt files into the TMP directory under the name 123.txt.gz

Decompression: #gzip-D file.gz

#zcat file.gz view. gz File Contents


2, bzip2

Compression directory is not supported, BZIP2 can be directly with the file name can also be followed by-Z filename, in the current directory compression, the original file will disappear.

#bzip2 filename

Unzip:

#bzip2-D FILE.BIZP2

#bzcat file.bz2 view. bz2 File Contents


3. XZ

Compression directory is not supported, XZ can be directly with the file name can also be followed by-Z filename, in the current directory compression, the original file will disappear.

Syntax: xz-z filename

-D filename Decompression

#xzcat file.xz to view. XZ text content.

Specifies the decompression path for the extracted files, such as the XZ compressed file as 1.txt.xz

#xz-D 1.txt.xz-c >/tmp/1.txt


4, Zip&unzip

Zip followed by file compression after the filename and then with the file to be compressed, in the current directory compression, the original file will disappear, support compression directory but to add-r

Compression: #zip 1.txt.zip 1.txt

Specify the compression path:

#zip/tmp/a/1.txt.zip/tmp/1.txt compress the/tmp/1.txt to/tmp/a/under the text to 1.txt.zip

Compression directory: #zip-R yasuo.zip yasuo/

Decompression: #unzip 1.txt.zip

#unzip-L File.zip lists the list of file.zip files

Extract to specified directory: #unzip-D/home/1.txt.zip


5. Tar Packaging

#tar-cvf file.tar file1 file2 dir1 ...

#tar-tf File.tar View the list of compressed package files

Decompression: #tar-XVF 1.tar

Specify path decompression: #tar-C/yasuo/hello-xvf 1.tar or #tar-xvf 1.tar-c/yasuo/hello


6. Tar package and compress and use

TAR supports gzip bzip2 XZ format compression

Gzip format compression

#tar-zcvf-z means using gzip compression,-TF view a list of files for a package or compressed package

such as: # TAR-ZCVF 1.tar.gz 111 111.zip 1.txt

# TAR-TF 1.tar.gz

#tar-ZXVF unzip. tar.gz file

such as: TAR-ZXVF 1.tar.gz

Specify directory Decompression: #tar-zxvf 1.tar.gz-c nihao/

#tar-ZXVF 1.tar.gz

BZIP2 format compression

#tar-jcvf file.tar.bzip2 fil1 file2 dir1 ...

such as: [[email protected] hello]# TAR-JCVF 1.tar.bzip2 Nihao/yasuo

Decompression: #tar-JXVF 1.tar.bzip2

XZ format compression:

#tar-jcvf file.tar.xz file1 file2 dir1 ...

Decompression: TAR-JXVF FILE.TAR.XZ

--exclude filtering some content when packaged or compressed

Example: #tar--exclude 12.txt--exclude AMINGLINUX-CVF 111.tar 111

#tar--exclude 12.TXT-CVF 111.tar 111

If you want to append a new file in 1.tar 1.txt premise is 1.tar when packaged, compression is not supported.

TAR-RF 1.tar 1.txt

[Email protected] hello]# TAR-RF 1.tar 2.txt

[Email protected] hello]# TAR-TF 1.tar

111/

1.txt

1.txt

2.txt




Compression and decompression of Linux note files gzip, bzip2, XZ, Zip&unzip, tar Pack, tar Pack and compress and use

Related Article

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.