What's wrong with this tar command?
$ tar --exclude='/tmp/test/exclude-me' -zcvf test.tar.gz test
test/
test/c.txt
test/exclude-me/
test/exclude-me/b.txt
test/a.txt
As you can see, exclude-me
is present when I untar the archive. I also tried --exclude=/tmp/test/exclude-me/*
.
The exclude
family of parameters apply to the internal relative names of the files in the tarball. The absolute path you specify will never exist within the tarball since it only has relative paths from the provided root.
You have to omit the absolute parts of the path.
In your example you use the v-flag and the included files are listed.
The exclude pattern is matched against the entries of this list, not to the actual file paths. So you have to change your pattern to "test/exclude-me".
For some reason you also have to remove the trailing / for folders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With