When rsyncing directory src
to dest
, is there any way I can make dest
contain the last k
sub-directories, in lexicographical order, of directory src
, as in a moving window where sub-directories having fallen outside of the window are automatically removed from dest
when re-running the same command at a later time?
For example, if k
= 2, src
contains
dir_1
dir_2
dir_3
dir_4
dir_5
and dest
is empty, after running rsync
, dest
should contain dir_4
and dir_5
. When, at a later time src
, contains
dir_1
dir_2
dir_3
dir_4
dir_5
dir_6
and rsync
is run again (with the very same command line), I want dir_4
to be deleted from dest
, replaced by dir_6
.