trying to understand --include and --exclude

Phil Howard phil-rsync-2 at
Sun Nov 27 17:10:39 GMT 2005

I was under the impression that --include and --exclude worked by matching
patterns in the order given, and whichever matched first, whether that was
an include or exclude determined the action for that file.  I have a big
directory from which I am attempting to transfer selected files.  I want
all files where the first level directory is anything, the second level
directory is "2005" and the third level is the file "07.tar.bz2".  So I
started with these options (different tries on each line):

    --include '**/2005/07.tar.bz2' --exclude '**'
    --include '**/2005/07.tar.bz2' --exclude '*'
    --include '*/2005/07.tar.bz2' --exclude '**'
    --include '*/2005/07.tar.bz2' --exclude '*'

I also tried numerous other random variations.  Either I get absolutely no
files at all matching, or I get everything in the entire directory tree to

I hope what I want is clear to you.  How can I make it clear to rsync?

I've had several other cases of this in the past, and stumbled on something
that worked without really understanding why.  So I guess the explanations
in the man page just didn't really give me the correct understanding of how
this works.  Maybe someone can try explaining in another way.

| Phil Howard KA9WGN       | |
| (first name) at | |

More information about the rsync mailing list