PDA

View Full Version : tar --exclude question


lepton
09-09-2002, 12:08 AM
I'm still on the "learning curve" %) for shell commands, so go easy on me if this is a really dumb question.

I don't understand why the first tar --exclude doesn't work (the second one does):

[xxxxxxxx@FQ-Hanna:/big/dom/xsrmsc ]$ tar -cvzf test0.tar.gz ./temp --exclude *.gz
./temp/
./temp/keywords.txt
./temp/perl.htm
./temp/srchsub.txt
./temp/scan_admin.zip
./temp/bkup.txt
./temp/email.txt
./temp/bkupold.txt
./temp/bkupold1.txt
./temp/buildprc.txt
./temp/xref#.txt
./temp/.bash_profile_orig
./temp/webbox.txt
./temp/bkupold2.txt
./temp/index.20020830.txt.gz <--- ? included
./temp/buildprc_old.txt
./temp/letter.txt
./temp/sall01.txt

[xxxxxxxx@FQ-Hanna:/big/dom/xsrmsc ]$ tar -cvzf test1.tar.gz ./temp --exclude index.*.txt.gz
./temp/
./temp/keywords.txt
./temp/perl.htm
./temp/srchsub.txt
./temp/scan_admin.zip
./temp/bkup.txt
./temp/email.txt
./temp/bkupold.txt
./temp/bkupold1.txt
./temp/buildprc.txt
./temp/xref#.txt
./temp/.bash_profile_orig
./temp/webbox.txt
./temp/bkupold2.txt <--- not included
./temp/buildprc_old.txt <---
./temp/letter.txt
./temp/sall01.txt

Terra
09-09-2002, 12:57 AM
tar -cvzf test0.tar.gz ./temp --exclude *.gz
You need to prevent the shell from expanding the wildcard before passing off to tar...

Try:
tar -cvzf test0.tar.gz ./temp --exclude '*.gz'

--
Terra
sysAdmin
FutureQuest

lepton
09-09-2002, 10:21 AM
'*.gz' works as expected with the quotes. Thanks, Terra.

Terra
09-09-2002, 10:33 AM
You're welcome - glad it worked out for you as desired...

--
Terra
--for the sake of argument(s), bash has a way of globbing up the execution of command--
FutureQuest