On Thu, Jun 02, 2005 at 11:48:00PM -0400, Winston Smith wrote: > One way to test exclude patterns is with > > tar -c --exclude=pattern includedirectorys | tar -t - > > Unfortunately, I didn't run such a test before responding to the > original poster, and now that I have I would like to retract my previous > posts on the subject. Sorry! > > The examples below show that the stripping of the leading / by tar is > not the issue as I thought it was.
I should add that the problem of the original poster was caused by the presence of the leading slash in the exclude patterns and its absence in the included files (tar wasn't stripping the leading slash in the exclude patterns because there was no leading slash in the included files). The problem is that the exclude patterns have absolute paths while the included files have relative paths. > $ rm -fr /tmp/{a,b} > $ mkdir -p /tmp/a/b /tmp/b/tmp/a/c # absolute relative $ cd /; tar -c --exclude=/tmp/a tmp/{a,b} | tar -t -f - tmp/a/ tmp/a/b/ tmp/b/ tmp/b/tmp/ tmp/b/tmp/a/ tmp/b/tmp/a/c/ # Nothing is excluded as in the case of the original poster. Changing the exclude patterns to relative paths without using "--anchored" before the exclude patterns can exclude too much: $ cd /; tar -c --exclude=tmp/a tmp/{a,b} | tar -t -f - tmp/b/ tmp/b/tmp/ # Directory tmp/b/tmp/a is excluded. $ cd /; tar -c --anchored --exclude=tmp/a tmp/{a,b} | tar -t -f - tmp/b/ tmp/b/tmp/ tmp/b/tmp/a/ tmp/b/tmp/a/c/ # The desired result. Changing everything to absolute paths also works: $ tar -c --exclude=/tmp/a /tmp/{a,b} | tar -t -f - tar: Removing leading `/' from member names tmp/b/ tmp/b/tmp/ tmp/b/tmp/a/ tmp/b/tmp/a/c/ # The desired result. This also works. $ cd /; tar -c --exclude=./tmp/a ./tmp/{a,b} | tar -t -f - Winston -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]