rsync using wildcard (*) character

Matt McCutchen matt at
Fri May 30 00:48:33 GMT 2008

On Thu, 2008-05-29 at 12:07 -0700, Meeaz wrote:
> If I run the following command using include option, it does not copy the
> first file from under "/opt/bea/test " directory
> rsync -arv --include /opt/bea/test/z* ddef at rclok95:/var/log/Wlog/TEST
> Note that the rest of the files are copied. Where am I going wrong?

Do this:

rsync -arv --include='/z*' --exclude='/*' /opt/bea/test/ ddef at rclok95:/var/log/Wlog/TEST

Include/exclude rules do not take the place of source arguments
like /opt/bea/test/ ; rather, they make rsync skip some of the files
specified by the source arguments.  All an "include" rule does is
override later "exclude" rules.  Thus, the literal meaning of the
command above is to send all of /opt/bea/test/ but skip all top-level
files that do not begin with "z", which amounts to what you want.  See
the "FILTER RULES" section of the man page for much more information.

Your command sent most of the files because you let the shell expand the
wildcard; the first file became the include pattern (which had no
effect) and the rest became source arguments.  Prevent the shell from
doing that by quoting the wildcard.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url :

More information about the rsync mailing list