anchoring of patterns for per-directory merge files

Andy Smith andy at
Wed Nov 11 10:59:29 MST 2009

Hi Paul,

On Wed, Nov 11, 2009 at 06:43:33PM +0100, Paul Slootman wrote:
> From the manpage:
>    The following modifiers are accepted after a “+” or “-”:
>    o      A / specifies that the include/exclude rule  should  be  matched
>           against the absolute pathname of the current item.  For example,
>           “-/ /etc/passwd” would exclude the  passwd  file  any  time  the
>           transfer  was  sending  files from the “/etc” directory, and “-/
>           subdir/foo” would always exclude “foo” when it is in a dir named
>           “subdir”,  even if “foo” is at the root of the current transfer.
> Hence, your dir-merge setup causes only the absolute path /tmp/ to be
> excluded. If you want to exclude /data/home/andy/tmp/ then put that in
> your .rsync-filter .

Neither "-/ /data/home/andy/tmp/" nor "- /data/home/andy/tmp/" nor
"-/ /home/andy/tmp/" match. (I'd already tried the middle one,

> The leading slash behaves differently in a dir-merge rule than in a
> "normal" include file.

That's what I was counting on, as the manual says:

        Anchoring Include/Exclude Patterns

        As mentioned earlier, global include/exclude patterns are
        anchored at the 'root of the transfer' (as opposed to
        per-directory patterns, which are anchored at the
        merge-file's directory). If you think of the transfer as a
        subtree of names that are being sent from sender to
        receiver, the transfer-root is where the tree starts to be
        duplicated in the destination directory. This root governs
        where patterns that start with a / match.

Which to me implies that if I start the path with a / then it should
be referring to the same directory that the merge file is in.

> At least, that's how I read the manpage :-)

It's possible, but your interpretation does not work for me either.


More information about the rsync mailing list