11 September 2006
Excluding specific file types using GNU tar
Posted by Mikhail Esteves under: LAMP; Tips .
You can specifically stop tar from archiving certain file types based on patterns (shell wildcards). For example, to archive everything in a directory excluding PDF and DOC files:
tar czvf archive.tgz --exclude=*.doc --exclude=*.pdf *
That creates a gzipped tarball with everything in the current directory minus PDF and DOC files. You can specify multiple --exclude parameters.