0

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?

Pota Onasys
  • 169
  • 1
  • 4

3 Answers3

2

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

Pota Onasys
  • 169
  • 1
  • 4
1

The arguments come before the files.

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

will work.

tastytea
  • 111
  • 2
0

try...

tar hczf t.tar.gz * --exclude="test1"
soupmagnet
  • 121
  • 5