user1654183 user1654183 - 1 year ago 106
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.

Answer Source

You need to use the --exclude option:

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download