include exclude help please.

Dave Dykstra dwd at bell-labs.com
Fri Mar 22 09:10:57 EST 2002


On Thu, Mar 21, 2002 at 03:24:39PM -0600, Joe Rice wrote:
> 
> 
> Dave Dykstra(dwd at bell-labs.com)@Thu, Mar 21, 2002 at 10:17:46AM -0600:
> > Let me explain Wayne's answer a little further.  The main thing you need to
> > understand is that the exclude algorithm is applied recursively so any time
> > there's an exclude that matches a directory, rsync will not descend any
> > further so if you're using --exclude '*' you need to include all
> > directories above what you want to copy.  Also, the basename of the source
> > directory is included in the patterns if the source directory doesn't end
> > with a slash.  This would be the straightforward answer:
> > 
> >     rsync -avv --include "/film/" --include "/film/jonah/" \
> > 	--include "/film/jonah/**/" --include "/film/jonah/**/sourceimages/ \
> > 	--include "/film/jonah/**/sourceimages/*.tif" --exclude "*" /film /tmp
> > 
> 
> thanks. this worked (almost):
> rsync -avv --include "/film/" --include "/film/jonah/" \
> --include "/film/jonah/**/" --include "/film/jonah/**/sourceimages/" \
> --include "/film/jonah/**/sourceimages/*.tif" --exclude "*" /film /tmp
> 
> it got all the tiff that were located in a directory somewhere under /film/jonah
> named sourceimages. but for some reason it also picked up these:
> 
> find ./ -iname \*.tif | grep -v sourceimages
> ./dept/concept/CHUCK_VOLLMER/hard drive/Documents/.Chuck's In Progress/jonah/master_paintings/treeflats/openingshothill.tif
> ./dept/concept/CHUCK_VOLLMER/treeflats/openingshothill.tif
> ./dept/concept/JOE_SAPULICH/Ship Hold Final.tif
> ./dept/concept/JOE_SAPULICH/ad tiffs/Location6_PirateShip/Sets/final_Pirate_ship ext.tif
> ./dept/concept/JOE_SAPULICH/ad tiffs/Ship Hold Final.tif
> ./dept/concept/JOE_SAPULICH/ad tiffs/joppa_tent_final.tif
> ./dept/concept/JOE_SAPULICH/final_pirate_ship_ext.tif
> ./dept/concept/findByContent/Approved_Ebinder/Location6_PirateShip/Sets/final_Pirate_ship ext.tif
> ./dept/lighting/dan/renderData/iprImages/rest8.tif

Very strange.  I don't know what to tell you.  Are you sure those weren't
copied by another command?

I just remembered that -vv now reports very useful information about what
includes/excludes are doing.  Try using that to see what's going on.


> > Ah, this is probably the best way to go, but you need a trailing slash on
> > the end of each of the directories or else the "sourceimages" is going to
> > get excluded by the --exclude '*'.  Try piping the find through
> >     sed 's,$,/,'
> 
> 
> rsync -rvv --relative --include='*.tif' --exclude='/*' `find /film/jonah -type d -name sourceimages -print | sed 's,$,/,' `  /tmp

> 
> almost worked but for some reason picked up everything under the
> sourecimages directories.

Oh, sorry, exclude patterns with --relative are the whole name so you the
--exclude '/*' isn't right.  It should be --exclude '*'.  Unfortunately, I
just tried that on a test case and it too had a problem.  -vv revealed that
with --relative and --exclude '*' you also need a --include '.'.  Very
non-intuitive indeed, I expect it should be fixed.  I vaguely recall
running into this once before.

- Dave




More information about the rsync mailing list