[NTLUG:Discuss] tar --exclude doesn't

Jack Snodgrass jack at jacksnodgrass.com
Wed Oct 1 16:23:11 CDT 2003


On Wed, 2003-10-01 at 16:05, Courtney Grimland wrote:

> >  From the man page:
> > 
> >   --exclude=FILE
> >         exclude file FILE
> > 
> > Please note, a single file, no globbing promised.
> > 
> > [globbing, a.k.a wildcard expansion; in general unix utils don't do
> > this 
> > themselves, the shell does it for you and passes the now multiple
> > args to the 
> > program (or the wildcarded string if there is no expansion
> > possible)]
> 
> [root at mercury ~]# tar --help | grep exclude
>     --exclude=PATTERN      exclude files, given as a globbing PATTERN
> -X, --exclude-from=FILE    exclude globbing patterns listed in FILE
> 
> 
> Quoting the PATTERN with single quotes should tell the shell not to
> do it's own expansion, but I still get the same results no matter how
> I quote it.  I agree that your approaches both should work, given
> what I've found that works and what doesn't.  I was more concerned
> with whether or not I was misinterpreting something, or if tar was
> simply not doing what it says it will do.
> 


I never could get exclude to work with tar either. I ended up doing
something 
like this:
find /directory-I-want-to-tar-up -type f | egrep -v
"/stuff|/I|/want|/to|/exclude" | 
tar cvzf tarfile.tgz -T -

basically, I use find to get the list of files, egrep to exclude the
files I don't want, 
and then use -T with stdin (-) to pass the filenames I want to include
to tar. 

jack




More information about the Discuss mailing list