tags:

views:

51

answers:

1

I have a tarball, and i want to remove all .tcl, .bat , .log files except pkgIndex.tcl in it.

if i do

tar --delete -f mytarball.tar --wildcards *{.tcl,.log,.bat}

my pkgIndex.tcl will be deleted, how to put that as exception in my pattern wildcard?

Just tried

tar  --delete -f mytarball.tar --wildcards *{.tcl,.log}  --exclude=*pkgIndex.tcl

and

tar  --delete -f mytarball.tar --wildcards *{.tcl,.log}  --exclude=pkgIndex.tcl

To no avail...

+1  A: 

Looks like GNU tar ignores --exclude when you use --delete.

You can do tar tf mytarball.tar --wildcards *{.tcl,.log} | grep -v pkgIndex.tcl | tar --delete -f mytarball.tar -T - instead. That will list all of the files matching *.tcl or *.log, grep for everything but pkgIndex.tcl, and pipe the list back into tar which will remove those files from the tarball.

DerfK