0

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?

1 Answers1

1

Try the --anchored option.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • Worked perfectly. Thanks! This page was helpful: http://www.gnu.org/software/tar/manual/html_node/controlling-pattern_002dmatching.html – Justin Russell Dec 29 '11 at 20:22