include/exclude patterns to copy just certain files?

Wayne Davison wayned at
Tue Jul 6 04:29:52 GMT 2004

On Sat, Jul 03, 2004 at 05:25:05PM -0600, Bob Proulx wrote:
>   rsync -a --include '*/' --include '**/a1/foo' --exclude "*" .

Yes, that is the way to use include/exclude without first figuring
out where all the foo files are.  As you noted that results in all
directories in the tree being created.

The easiest way around this is to switch from include/exclude to using
the --files-from option, like this:

find . -name foo | rsync -a --files-from=- .


More information about the rsync mailing list