[Cialug] rsync --recursive *.foo

David Champion dave at visionary.com
Wed Aug 10 14:21:52 CDT 2005


Josh More wrote:
>>From the man page: 
>  
>             --exclude=PATTERN       exclude files matching PATTERN 
>             --include=PATTERN       don't exclude files matching PATTERN
>  
> So you might be able to do an --exclude='*' --include='*.foo' 
>  
> You need the * in single quotes so that the shell will not expand it. 
> That is what is harming you now. 
>  
> If this fails, you can use find to generate a list of matches and feed 
> rsync a file list. 

Ah, this got me on the right path. Here's my magical incantation :

rsync -azve ssh --include "*/" --include="*.foo" --exclude "*" * 
user at hostname:~/temp/

See the man page's info on --exclude pattern matching. It has its own 
special expression style that's not quite like regular expressions, and 
not quite like ms-dos style wildcards. In the example above, I'm telling 
it to match all directories with "*/", to match "*.foo", but to exclude 
everything else with "*". The "--recursive" parameter is apparantly 
superflous in this case because of the pattern matching.

Some notes from the other helpful hints:

Jerry's idea might work - I never got it quite running with the "-" for 
stdin on the rysnc side, probably just an option placement issue. BTW - 
in linux the "-depth" and "-print" parameters to find are apparantly the 
defaults, the placement of the "-depth" parameter at the end, it did not 
like either.

Jon's example works exactly like my original example.

-dc



More information about the Cialug mailing list