Exclude specific folders when "original" Linux compresses folders

Source: Internet
Author: User

Compression decompression files under Linux This is a very common command, we need to pack the files very often to do the transfer or other operations.

Sometimes the company's programmers need to download the program that is running the site, need to pack, but for example, the backup folder has more than 10 g, upload pictures of the folder is also very large, you can not write the other folders again?

By looking, I also found two ways to share with you here

1. $ (ls | grep-v xx)

TAR-ZCF tmp.tgz $ (ls | grep-v xx)

grep-v: anti-retrieval, displaying only rows that do not match. This excludes specific folders. This method also applies with the zip command.

2.--exclude

When you compress a directory, sometimes you want to exclude a directory

For example, if the 123 directory has 3 subdirectories, AA, BB, CC. I now want to package only the AA and BB directories for compression, the command is as follows:

TAR-ZCVF 123.tar.gz  --EXCLUDE=CC 123

(Running outside of the 123 directory) uses the exclude parameter to filter unwanted directories or files, excluding the operation and directory of a file.

Exclude specific folders when "original" Linux compresses folders

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.