Linux under Compression and packaging tools--gzip, bzip2 and tar;

Source: Internet
Author: User
Tags bz2

The following is from: Amin http://www.apelearn.com/study_v2/chapter11.html, the commonly used to write, the feeling can be;

Just compress and unzip the tool: Gzip Tool:

Just remember these parameters when you use them: NOTE: gzip cannot compress the directory;

    • -D, which indicates decompression, without adding parameters when compressing;
    • -K, which indicates keep, if not added, the original file disappears when it is compressed or decompressed, and the original file does not disappear when added –k;

After compressing the file, the suffix name is. gz, as in the following example:

gzip -k hello.c[email protected]:lshello.c  hello.c.gz

Unzip:

gzip -D-k hello.c.gz [email protected]:lshello.c  hello.c.gz

BZIP2 Tools:

Its usage is similar to the above tools, we remember these three parameters: note: bzip2 also not to compress the directory;

    • -Z means compression; can be omitted;
    • -d means decompression;
    • -K, which indicates keep, if not added, the original file disappears when it is compressed or decompressed, and the original file does not disappear when added –k;

When compressing, it compresses the suffix of the file after it has increased. bz2; examples are as follows:

bzip2 -z hello.c[email protected]:lshello.c.bz2

Unzip:

bzip2 -d hello.c.bz2 [email protected]:lshello.c

Packaged compression: The Tar tool:

Tar itself is a packaging tool, but it can also be compressed, remember the above mentioned two tools can not be compressed directory, how to do??? Workaround: We can first package a directory into a file, and then compress; so use tar to do it;

We just need to remember the following parameters to be able to;

-X: Unpacking or decompressing

-C: Build a tar package or zip file package

-Z: Simultaneously with gzip compression

-j: Simultaneous compression with bzip2

-T: View the files inside the tar package

-V: Visualize

-F: followed by the file name, compressed with "-F file name", meaning the compressed file name is filename, decompression with "-f filename", meaning is to extract filename. Note that if you have multiple parameter combinations with "-F", write "-F" to the last face.

Example: Use gzip compression after packaging:

tar -czvf dir1. Tar . GZ dir1dir1/dir1/hello.c[email protected]:lsdir1  dir1. tar. GZ  dir2  hello.c
Decompression and unpacking;
tar -xvf dir1. Tar . GZ          //(in fact, it doesn't matter if you add Z-parameters, I see others are added) Dir1/dir1/hello.c[email protected]:~/trial$

To view the contents of a compressed package:

tar -tf dir1. Tar . GZ dir1/dir1/hello.c

Know these, usually use is enough;

Linux under Compression and packaging tools--gzip, bzip2 and tar;

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.