Home Explore Blog CI



man-pages

79th chunk of `rsync.man`
32444751a0e1827d78abd3b809cf62e926c633edded4f3260000000100001002
     are within the transfer).

       o      A pattern that ends with a / only matches a directory, not a reg‐
              ular file, symlink, or device.

       o      A pattern that starts with a / is anchored to the  start  of  the
              transfer  path  instead  of  the  end.   For  example, /foo/** or
              /foo/bar/** match only leading elements in the path.  If the rule
              is read from a per‐directory filter file, the transfer path being
              matched will begin at the level of the filter file instead of the
              top of the transfer.  See the section  on  ANCHORING  INCLUDE/EX‐
              CLUDE  PATTERNS for a full discussion of how to specify a pattern
              that matches at the root of the transfer.

       Rsync chooses between doing a simple string match and wildcard  matching
       by  checking if the pattern contains one of these three wildcard charac‐
       ters: ’*’, ’?’, and ’[’ :

       o      a ’?’ matches any single character except a slash (/).

       o      a ’*’ matches zero or more non‐slash characters.

       o      a ’**’ matches zero or more characters, including slashes.

       o      a ’[’ introduces a character class, such as [a‐z] or [[:alpha:]],
              that must match one character.

       o      a trailing *** in the pattern is a shorthand that allows  you  to
              match  a directory and all its contents using a single rule.  For
              example, specifying "dir_name/***" will match both the "dir_name"
              directory (as if "dir_name/" had been specified)  and  everything
              in the directory (as if "dir_name/**" had been specified).

       o      a backslash can be used to escape a wildcard character, but it is
              only  interpreted as an escape character if at least one wildcard
              character is present in the match pattern. For instance, the pat‐
              tern "foo\bar" matches that single backslash literally, while the
              pattern "foo\bar*" would need to be  changed  to  "foo\\bar*"  to
              avoid the "\b" becoming just "b".

       Here are some examples of exclude/include matching:

       o      Option -f’- *.o’ would exclude all filenames ending with .o

       o      Option  -f’- /foo’  would exclude a file (or directory) named foo
              in the transfer‐root directory

       o      Option -f’- foo/’ would exclude any directory named foo

       o      Option -f’- foo/*/bar’ would exclude any file/dir named bar which
              is at two levels below a directory named foo (if foo  is  in  the
              transfer)

       o      Option  -f’- /foo/**/bar’  would  exclude  any file/dir named bar
              that was two or more levels below a top‐level directory named foo
              (note that /foo/bar is not excluded by this)

       o      Options -f’+ */’ -f’+ *.c’ -f’- *’ would include all  directories
              and .c source files but nothing else

       o      Options -f’+ foo/’ -f’+ foo/bar.c’ -f’- *’ would include only the
              foo directory and foo/bar.c (the foo directory must be explicitly
              included or it would be excluded by the "- *")

   FILTER RULE MODIFIERS
       The following modifiers are accepted after an include (+) or exclude (-)
       rule:

       o      A  /  specifies  that  the include/exclude rule should be matched
              against the absolute pathname of the current item.  For  example,
              -f’-/ /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.

       o      A ! specifies that the include/exclude should take effect if  the
              pattern  fails  to  match.  For instance, -f’-! */’ would exclude
     

Title: Rsync Pattern Matching Rules and Filter Modifiers
Summary
The section elaborates on rsync's pattern matching: '?' matches any single non-slash character, '*' matches zero or more non-slash characters, and '**' matches zero or more characters including slashes. '[...]' denotes character classes, and a trailing '***' matches a directory and its contents. Backslashes escape wildcards. Examples clarify include/exclude matching for files and directories. It covers the absolute pathname modifier ('/') and negation modifier ('!') to include/exclude rules, which alter the match criteria based on absolute paths or failed pattern matching.