Regras de filtro globais rsync que começam com um / inicial estão ancoradas na raiz da transferência. Citando a seção "INCLUDE / EXCLUDE PATTERN RULES" da página man:
if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular expressions. Thus "/foo" would match a name of "foo" at either the "root of the transfer" (for a global rule) or in the merge-file's directory (for a per-directory rule).
Em seu comando ( rsync ... -arv /home/ben home-ben/ ), o arquivo /home/ben/foo seria transferido para home-ben/ben/foo . A raiz da transferência é home-ben e o caminho correto do filtro é /ben/foo . Assim,
- para corresponder a
/home/ben/.ccache, você precisa de um caminho de filtro de/ben/.ccache - para corresponder a
/home/ben/build/, você precisa de um caminho de filtro de/ben/build/
Uma explicação mais detalhada pode ser encontrada na seção "ANCORAGEM INCLUIR / EXCLUIR PADRÕES" do rsync(1) man página .
Note que simplesmente deixar de fora o primeiro / não é necessariamente o que você deseja. Citando novamente a partir da mesma seção da página man:
An unqualified "foo" would match a name of "foo" anywhere in the tree because the algorithm is applied recursively from the top down; it behaves as if each path component gets a turn at being the end of the filename. Even the unanchored "sub/foo" would match at any point in the hierarchy where a "foo" was found within a directory named "sub". See the section on ANCHORING INCLUDE/EXCLUDE PATTERNS for a full discussion of how to specify a pattern that matches at the root of the transfer.
Assim, um padrão de filtro de build/ corresponderia a um diretório de criação em qualquer lugar em /home/ben , mesmo /home/ben/many/sub/directories/build/ .