Running the tar command with the –exclude functionality does not work for directories

tar

I use

tar hczf t.tar.gz * --exclude="./test1"

where test1 is the name of a directory that I want to prevent from being tarred.

Unfortunately, tar still includes the directory test1. How can I have tar exclude directories?

Best Answer

So it turns out that to prevent the tarring of a directory you need to change where you're adding the --exclude

tar --exclude="./test1" -hczf t.tar.gz *

works

Related Topic