How to avoid copying empty directories?

Martin Pool mbp at samba.org
Thu Nov 29 09:23:18 EST 2001


On 28 Nov 2001, Dave Dykstra <dwd at bell-labs.com> wrote:
> On Tue, Nov 27, 2001 at 04:03:58PM -0800, btang at pacific.jpl.nasa.gov wrote:
> > rsync -avu --include 'tmp1/*/*.c' --include "*/" --exclude "*" tmp1 tmp2
> > 
> > The above command copies all the empty directories under tmp1/ . Is there
> > any way to avoid it?
> 
> Currently the only way is to explicitly include the parent directories
> you want instead of --include "*/".

A quick fix is to post-process the directory with 

  find tmp2 -type d -empty -depth -exec rmdir {} \;

I think the best fix is to add scripting support:

  rsync -avu --perl 'filter() { ( -d && -s ) || /\.c$/; }' here friendly:/tmp

Anybody else like this idea?

--
Martin




More information about the rsync mailing list