Excluding specific file types using GNU tar

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.

  • Share/Bookmark

Leave a comment

Your comment