Filter file: selected directories only

Matt McCutchen matt at mattmccutchen.net
Thu Oct 8 23:13:46 MDT 2009


On Thu, 2009-10-08 at 03:17 +0400, rsync at xbit.ru wrote: 
> Thank you, it works.
> 
> But if I want to delete only certain files or dirs from remote side?
> 
> example:
> 
> $ tree dirA/
> dirA/
> |-- dir2
> |   `-- file3
> |-- file1
> `-- file2
> 
> $ tree dirB/
> dirB/
> |-- dir2
> |   `-- file3
> |-- file1
> |-- file2
> `-- protect1
> 
> $ rsync -av --dry-run --delete-excluded -f ". filter" dirA/ dirB/
> building file list ... done
> ./
> 
> sent 74 bytes  received 26 bytes  200.00 bytes/sec
> total size is 0  speedup is 0.00
> 
> $ cat filter
> H *
> P *
> R dir2*
> - dir2*
> 
> I want to delete "dirB/dir2/" only. Not "dirB/protect1" or any other
> file or dir in "dirB/".
> What sort of filter I must create?

"rm -r dirB/dir2"?  I don't think I understand your point here.

> Where can I find example filter files for complicated cases?

There are a few examples scattered throughout the man page, but I don't
know of any really good tutorial.

-- 
Matt



More information about the rsync mailing list