user1654183 user1654183 - 9 months ago 74
Linux Question

tar/gzip excluding certain files

I have a directory with many sub-directories. In some of those sub-directories I have files with

extension and some with

I want to create a SINGLE tarball/gzip file which maintains the directory structure but excludes all files with the

How can I do this?

I did something like
find . -depth -name *.asc -exec gzip -r9 {} +
but this gzips every
file individually which is not what I want to do.


You need to use the --exclude option:

tar -zc -f test.tar.gz --exclude='*.xdr' *