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

Try the --anchored option.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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