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)