Re: How to avoid copying empty directories?

2001-11-28 Thread Dave Dykstra

On Tue, Nov 27, 2001 at 04:03:58PM -0800, [EMAIL PROTECTED] 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 */.

- Dave Dykstra




Re: How to avoid copying empty directories?

2001-11-28 Thread Martin Pool

On 28 Nov 2001, Dave Dykstra [EMAIL PROTECTED] wrote:
 On Tue, Nov 27, 2001 at 04:03:58PM -0800, [EMAIL PROTECTED] 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




Re: How to avoid copying empty directories?

2001-11-28 Thread Dave Madole


I agree with this - a perl script to generate a list of includes from a list of
directories
is not hard to write (below in long and readable rather than compact perly
form), and what about --python and  --awk:

#cat frag.pl
#!/usr/bin/perl -w
# frag.pl - perl fragment for generating include list for rsync
   my $includes = ;
my %already = ();
my @pathlist = ;
foreach my $path (@pathlist) {
  chop $path;
my @subdirs = split(/\//,$path);
my $dirs;
foreach my $dir (@subdirs) {
$dirs .= $dir./;
unless(defined($already{$dirs})  $already{$dirs} eq included) {
$includes .=  --include .$dirs;
$already{$dirs} = included;
}
}
$includes .=  --include $path/**;
}
$includes .=  --exclude \*\ ;
 print $includes,\n;

#cat test
dir1/local/src/dir1
dir2/local/bin
dir2/local/src

#cat test | ./frag.pl
 --include dir1/ --include dir1/local/ --include dir1/local/src/ --include
dir1/local/src/dir1/ --include dir1/local/src/dir1/** --include dir2/ --include
dir2/local/ --include dir2/local/bin/ --include dir2/local/bin/** --include
dir2/local/src/ --include dir2/local/src/** --exclude *


Dave Dykstra wrote:

 On Thu, Nov 29, 2001 at 09:23:18AM +1100, Martin Pool wrote:
  On 28 Nov 2001, Dave Dykstra [EMAIL PROTECTED] wrote:
   On Tue, Nov 27, 2001 at 04:03:58PM -0800, [EMAIL PROTECTED] 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?

 Nah, the best fix in this case is --files-from.  I'm not too keen on the
 scripting idea.  Seems like more bloat to me.  With --files-from people
 can use whatever script they like to generate the list of files before
 sending it to rsync.

 - Dave




How to avoid copying empty directories?

2001-11-27 Thread btang

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?