include exclude help please.

Joe Rice jrice at
Fri Mar 22 08:24:39 EST 2002

Dave Dykstra(dwd at, 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/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/findByContent/Approved_Ebinder/Location6_PirateShip/Sets/final_Pirate_ship ext.tif

> 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.

> I too can't wait to see "Jonah".  My kids have seen all the Veggie Tales
> and 3-2-1 Penguin videos.  Also, I live in the Chicago area and have run
> into a guy in my hometown's new library a couple times who told me he works
> on Penguin 3.  I'm delighted to know that rsync is helping Big Idea.

Wonderful! You should run out and buy the new Larryboy video that came out Tuesday.
It is 2D and animated in/with Flash.

Thanks for all your help,

More information about the rsync mailing list