Linux Learning Notes (iv) Archiving and compression

Source: Internet
Author: User

one, zip compression command:

1. Compress files:

Format: Zip compressed file source file

Example: Zip abc.zip ABC//compress the ABC file into the Abc.zip file.

2. Compression directory:

Format: Zip–r compressed directory source directory

Example: Zip dir.zip dir//The Dir directory is compressed into a dir.zip file.

3. Unzip the file:

To extract a command using the unzip:

Format: Unzip compressed file

Example: Unzip Abc.zip//shrinks the Abc.zip file. (Files and directories use the same decompression command)

Ii.. gz format Compression

1. Compress files

Format: gzip source file

Example: gzip abc.txt

Note: The source file disappears when you use the gzip compressed file

2. Compressed files do not delete source files

Format: gzip–c source files > Compressed files

Example: Gzip-c abc.txt > abc.gz//Compress source files into abc.gz format.

3. Compress all sub-files in the directory

Format: Gzip–r Directory

Example: GZIP–R/JP//Compress all sub-files in the JP directory, the source files in the directory disappear.

4. Unzip the file

Format: Gzip–d Compressed file

Example: Gzeip–d abc.gz

Or:

Format: Gunzip compressed file

Example: Gunzip abc.gz

Example: Gunzip–r JP//Unzip all sub-files in the directory:

Iii.. bz2 format Compression

1. Compress files

Format: bzip2 source file

Example: bzip2 abc.txt//Compressed Abc.txt file, do not retain the original file.

Example: bzip2 a.txt b.txt//colleague compresses a.txt and b.txt files without preserving the source files.

2. Keep source file compression

Format: bzip2–k source file

Example: Bzip2–k abc.txt//compress abc.txt file, keep source file

3. Decompression

1, Bzip2 Way

Format: Bzip2–d Compressed file

Example: Bzip2–d abc.bz2//decompression does not preserve source files

Example: BZIP2–DK abc.bz2//extract retention source files

2, Bunzip2 Way

Format: Bunzip2 Compressed file

Example: BUNZIP2 abc.bz2//decompression does not preserve source files

Example: Bunzip2–k abc.bz2//extract retention source files

Iv. Tar packaging commands

1. Packing

Format: TAR–CVF package file name source file

Options:

-Z: Compress files in tar.gz format

-j: Compressing files in tar.bz2 format

-C: Packaging

-V: Display procedure

-F: Specifies the file name after packaging

Example: TAR–CVF jp.tar JP//The JP directory is packaged as a Jp.tar format file.

Example: TAR–ZCVF jp.tar.gz JP//package and compress the JP directory

Example: TAR–JCVF jp.tar.bz2 JP//package and compress the JP directory

Example: tar–jcvf/tmp/jp.tar.bz2 jp1 JP2//Packaging compressed multiple folders to a specified directory

2. Unpacking

Format: TAR–XVF package file name

Options:

-Z: Unzip. GZ formatted files

-j: Compressing files in tar.bz2 format

-X: Unpacking

-T: View file contents

Example: TAR–XVF Jp.tar//Unpacking the Jp.tar

Example: TAR–ZXVF jp.tar.gz//Unpacking the jp.tar.gz

Example: TAR–JXVF jp.tar.bz2//Unpacking the JP.TAR.BZ2

Example: TAR–JXVF jp.tar.bz2-c/tmp//extract jp.tar.bz2 to the specified directory

Example: TAR–JTVF jp.tar.bz2//view contents in a compressed package

Linux Learning Notes (iv) Archiving and compression

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.