Linux tar compression command excludes a directory (summarized according to man Tar)

Source: Internet
Author: User

It is generally easy to package directly with the tar command, using TAR-ZCVF test.tar.gz test directly.

In many cases, we have to package a directory, and there are dozens of subdirectories and sub-files in this directory, we need to exclude 1, 2 directories or files when packaging.

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

For example:

We take Tomcat, for example, when packing we want to exclude the Tomcat/logs directory, the command is as follows:

TAR-ZCVF tomcat.tar.gz--exclude=tomcat/logs Tomcat

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

TAR-ZCVF tomcat.tar.gz--exclude=tomcat/logs--exclude=tomcat/libs--exclude=tomcat/xiaoshan.txt Tomcat

Linux tar compression command excludes a directory (summarized according to man 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.