Compression and decompression

Source: Internet
Author: User
Tags unzip archive

Compression and decompression & compress decompress

GZ; xz; zip/unzip; RAR/unrar; tar; targz/tgz; tarbz2


------- GZ -------

How to compress and retain source files

$ Gzip-c filename> filename.gz

Decompress and retain source files

$ Gunzip-C filename.gz> filename


------- Xz -------

Compress

$ Tar-CVF Folder/folder.tar

$ Xz-Z folder.tar. xz


Decompression

$ Xz-D folder.tar. xz

$ Tar-xvf folder.tar


------- Zip/unzip -------

. Zip exist on Linux | Windows | Mac OS, but the compression ratio is not good.

$ Zip-r archive.zip directory (compress folder)

$ Unzip archive.zip (decompress. Zip)


When decompress. Zip, have messy code.

$ Sudo apt-Get install p7zip-full convmv

$ Lang = C 7z x x.zip

$ Convmv-F cp936-T utf8-r -- notest * [Handle messy Code]


------- RAR -------

The compressed folder is in the RAR format. Extract files in the .rar format. It is recommended that you put the files to be compressed into the folder.

$ Sudo apt-Get install RAR (UBUNTU)

$ RAR a compress | compress.rar directory /*

[Compressed file. The generated compressed file can be RAR or not added. When not added, the system automatically adds a suffix.]

[When specifying a folder, it is best to add the/* Asterisk to compress the files or folders in the folder]

$ RAR x compress.rar [Extract]

$ RAR l compress.rar [list the content in the RAR package]


Note:

A-> add files to archive

E-> Extract files to current directory

X-> Extract files with full path



------- Unrar -------

Decompress. rar compressed files


Example:

$ Sudo apt-Get install unrar (UBUNTU)

$ Unrar x *. rar [Extract files with full path] decompress the inclusion folder

$ Unrar E *. rar [Extract files to current directory] Extract files without folders

$ Unrar L *. rar [list Archive] list content in the compressed package



------- Tar -------

. Tar only pack, not compress.

$ Tar-CVF archive.tar directory [comp folder]

$ Tar-xvf archive.tar [decomp. Tar to current folder]

$ Tar-xvf archive.tar-C exist_directory [decomp to exist folder]


Decompress a file in the package

$ Tar ztvf testingboobooke.tar.gz [query the list of files in the compressed package]

$ Tar zxvf testingboobooke.tar.gz testingbooboobooke/test. readme-o | more [directly output the file content to the standard output]


Decompress the file in the compressed package

$ Tar zxvf x.tar.gz x/XXX/


------- Tarbz2 -------

.Tar.bz2

$ Tar-jcvf archive.tar.bz2 directory [comp folder]

$ Tar-jxvf archive.tar.bz2 [decomp. Tar to current folder]

$ Tar-jxvf archive.tar.bz2-C existed_directory [decomp to existing folder]


------- Targz -------

.Tar.gz

$ Tar-zcvf archive.tar.gz directory [comp folder]

$ Tar-zxvf archive.tar.gz [decomp. Tar to current folder]

$ Tar-zxvf archive.tar.gz-C existed_directory [decomp to existing folder]


This article is from the "andyhdchoice" blog, please be sure to keep this source http://andyhdchoice.blog.51cto.com/1521623/1548752

Compression and decompression

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.