[PLUG] rsync excludes

Zot O'Connor zot at whiteknighthackers.com
Thu Nov 20 16:15:02 UTC 2003


On Thu, 2003-11-20 at 14:12, Michael Montagne wrote:
> In a quandry about why my --exclude-from file listing is not being
> excluded.
> I'm looking to exclude entire directoriesin this case and my file
> looks like this:
> -Transfer/
> -scans/
> -temp/
> -"Slide library"/
> 

Post the command line, the file name, and the file contents exactly to
the list.

The exclude commands is not intuitive, but makes sense after
understanding:

>From the man page:

  o      if  the  pattern  starts with a / then it is matched against the
              start of the filename, otherwise it is matched against  the  end
              of the filename.  Thus "/foo" would match a file called "foo" at
              the base of the tree.  On the other hand, "foo" would match  any
              file  called "foo" anywhere in the tree because the algorithm is
              applied recursively from top down; it behaves as  if  each  path
              component gets a turn at being the end of the file name.

       o      if  the  pattern  ends with a / then it will only match a direc-
              tory, not a file, link or device.

       o      if the pattern contains a wildcard character from  the  set  *?[
              then  expression  matching  is  applied using the shell filename
              matching rules. Otherwise a simple string match is used.

       o      if the pattern includes a double asterisk "**"  then  all  wild-
              cards  in  the  pattern  will match slashes, otherwise they will
              stop at slashes.

       o      if the pattern contains a / (not counting a trailing /) then  it
              is  matched  against  the  full  filename, including any leading
              directory. If the pattern doesn´t contain a / then it is matched
              only against the final component of the filename.  Again, remem-
              ber that the algorithm is applied recursively so "full filename"
              can actually be any portion of a path.

       o      if  the  pattern  starts  with "+ " (a plus followed by a space)
              then it is always considered an include pattern, even if  speci-
              fied  as  part  of an exclude option. The "+ " part is discarded
              before matching.

       o      if the pattern starts with "- " (a minus followed  by  a  space)
              then  it is always considered an exclude pattern, even if speci-
              fied as part of an include option. The "- "  part  is  discarded
              before matching.

       o      if  the  pattern is a single exclamation mark ! then the current
              include/exclude list is reset, removing all  previously  defined
              patterns.

So you might want to exclude files, paths, or both.  I often cheat and
do something like
find /path | grep 'pattern' > exclude file

This works 90% of the time, unless there are funky chars in the names.



> I've tried it without the leading "-".  I've also tried it using the
> fullpath.  It is a mounted windows drive (if that matters).  
-- 
Zot O'Connor

http://www.ZotConsulting.com
http://www.WhiteKnightHackers.com





More information about the PLUG mailing list