View Single Post

   
  #5 (permalink)  
Old 02-21-2008, 09:19 PM
Martin Boening
 
Posts: n/a
Default Re: exclude in tar command

Hi there,

On 2008-02-21, Peter Terpstra <peter@dharma.dyndns.invalid> wrote:
>
> Yes i know, but how?
>
> tar cvf --exclude="*.gz *.cf *.txt *.sh *.conf *.db" test.tar etc
>
> Creates just a file with that name and ends in an error (tar: Error exit
> delayed from previous errors).
>
> P.


the cvf parameter for tar expects the file name of the archive to follow
the 'f' argument real close. ;-) All further options need to follow later,
e.g.
tar cvf test.tar --exclude="*.gz" etc

The cvf is "old style" argument use and after giving the command options in
that style, the arguments for thos options must follow directly after the
option string in the order the option string specifies. Another example
would be

tar cvbf 20 /dev/rmt0 ...

if a blocking factor is required for writing to tape for example.
Alternatively, you can, of course, use new style options in almost any
order you like:

tar --create --file=test.tar --exclude="*.gz" --verbose etc

The --exclude can only take one pattern, IIRC. So you might try to find a
pattern that matches everything you want to exclude, have several
--exclude options on the command line or create a file containing all
exclude patterns, on per line, and then exclude from that:
tar cvf test.tar --exclude-from=patternfile etc

HTH
Martin
--
Martin Boening, mboen@t-online.de, Linux Registered User #258205

KERNEL: A part of an operating system that preserves the medieval
traditions of sorcery and black art.
Reply With Quote