[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Excluding a directory from tar



Quoting Petter Adsen (petter@synth.no):
> I've been trying to make a tarball of my home directory, but I want to
> exclude ~/.cache. First I tried '--exclude="~/.cache", but it didn't
> work. Neither did '--exclude="~/.cache/*".
> 
> I got it working by creating an empty file in ~/.cache and using the
> filename as an argument to "--exclude-tag-under", but what was I doing
> wrong when trying to use "--exclude"?

I didn't know tar did that. I thought most people use find to generate
the filenames for tar to act on.

Then you'd be using a command something like

find -xdev -path './cache' -prune -o -print | tar ...

and the other advantage of this method is that you pipe it into less
until you get the files you want, then only then substitute tar.

Have fun reading man find, though!

Cheers,
David.


Reply to: