tags:

views:

467

answers:

4

Hi,

How do I tar a list of files and folders (all in the same directory) with the exclusion of a single directory (which contains a huge amount of data)

+6  A: 

tar --exclude=PATTERN xvzf nameof.tar.gz ./*

PATTERN can be the directory name. GNU tar.

Zsolt Botykai
If you have part of a file/dir name that matches PATTERN, it will also get excluded from being backed up. This is a little dangerous.
deepwell
A: 

I think it may depend on your version of tar. You can use 'man tar' or 'tar --help' to check for details on your version. But the options I found are:

tar -X filename: excludes anything listed in the given text file
tar --exclude=pattern: excludes anything matching the pattern

Dave Costa
A: 

Hey thanks for the superfast response!

1 quick question though - do I need to add the individual files/folders to this command that I want tar'd or can I do something like "tar --exclude=MYEXCLUDEDDIRECTORY xvzf mydirectoryiwant.tar.gz ./mydirectoryiwant/

Ed Bloom
You can do --exclude=MYDIRECTORY.
Zsolt Botykai
A: 

actually just figured it out with your help - many thanks!

Ed Bloom
Then it's time to mark my answer as correct, and close the question.
Zsolt Botykai