pulling selected subdirs by wildcard

Dave Dykstra dwd at bell-labs.com
Wed Jan 30 09:35:49 EST 2002


On Mon, Jan 28, 2002 at 02:17:35PM -0600, Michael Brutsch wrote:
> I am trying to sync a tree, as follows:
> 
> /top
>   |-dir1
>   |  |-data
>   |
>   |-newdir
>   |  |-data
>   |
>   |-etc,etc
> 
> I need to pull just the 'data' directories, then push back
> everything BUT the data directories.
> 
> I tried this:
> 
> rsync --include "*/" --include "data/" --exclude "*"
> 
> but it just includes everything.  If I leave off the '--include
> "*/"', I get nothing.
> 
> My guess is that I'm not using the '--include "*/"' kludge properly.


--include '*/' says to include every directory.  If you want only a subset
of the directories, you will need to explicitly include the parent
directories of every directory you want (recursively).  If all of your
"data" directories happen to be exactly one level down as the example
shows, you may get away with --include "/*/" which signifies just the
top-level directories (plus you need --include "data/" and --exclude "*").

- Dave Dykstra




More information about the rsync mailing list