Common compression and decompression methods under Linux

Source: Internet
Author: User

Compression command:

tar.gz format: TAR-ZCVF custom compressed file name. tar.gz Compressed file name

Zip Format: Zip-r custom compressed file name. zip Compressed file name

If you want to compress the entire folder, you can also go to the directory where you want to compress the folder, and then run the TAR-ZCVF custom compressed file name. tar.gz *

Zip-r a custom compressed file name. zip *

Decompression command:

tar.gz format: TAR-ZXVF compressed file name. tar.gz

ZIP Format: Unzip compressed file name. zip

The unzipped file can only be placed in the current directory.

To exclude a file or folder method from a compressed file:

Many times we need to package a directory, and there are dozens of subdirectories and sub-files in this directory, we need to exclude one or two directories or a few files when we pack.

At this time we are packing with the tar command, add parameter --exclude can achieve the purpose.

We take myweb as an example, when packaging we want to exclude the myweb/logs directory, the command is as follows:

TAR-ZCVF myweb.tar.gz --exclude=myweb/logs myweb

If you want to exclude more than one directory, add--exclude, such as we want to exclude logs and libs two directories and file Readme.txt, the command is as follows:

TAR-ZCVF myweb.tar.gz --exclude=myweb/logs--exclude=myweb/libs--exclude=myweb/readme.txt myweb

It is important to note that when we use the tar--exclude command to exclude packaging, we cannot add "/", otherwise the logs directory and the files under it will be packaged in, for example:

TAR-ZCVF myweb.tar.gz--exclude=myweb/logs/ --exclude=myweb/libs/ MyWeb (This is the wrong wording)

TAR-ZCVF myweb.tar.gz--exclude=myweb/logs--exclude=myweb/libs myweb (This is the correct notation)

Common compression and decompression methods under Linux

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.