I'm working on doing a pretty straightforward tar for a site, but there's a wrinkle. Here's the file structure of the site:

...
files/
images/
images/visitors/
...
logs/
...
visitors/

Here's the problem: I want to exclude all the files in the main visitors/ directory, but I want all the files in the images/visitors/ directory to be included in the tarball.

I've been trying tar c --exclude-from='excludeList' with the following as the content of "excludeList":

excludeList
files/
visitors/

Unfortunately, since the files in images/visitors/ match the visitors/ pattern, they're excluded, too. In a perfect world, I could go regex with something like this:

excludeList
files/
^visitors/

But that doesn't work. Is there any way to make this work, either straight through tar or with another sort of pattern-matching command?

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

Try the --anchored option.

link|improve this answer
Worked perfectly. Thanks! This page was helpful: gnu.org/software/tar/manual/html_node/… – Justin Russell Dec 29 '11 at 20:22
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.