William Tambe wrote:
> Hi,
> Can you please add a synchronization feature to the GNU cp so that files
> not found in the source files/folders get removed from the destination
> folder?
> 
> This is a very useful feature for backups without having to use very
> expensive routines.
> 
> I know rsync provide a similar feature but it would be nice to have just
> a single option to the cp command to do the work without having to use
> another tool which has its own set of options and feature.

The unix way is to have specific tools for specific jobs

>         find . | while read file
>         do
>                 [ -e "/${file}" -o -L "/${file}" ] || rm -vrf ${file}
>         done

shell looping is slow BTW. Always try to push iteration into compiled logic.
For example you could do instead:

export LANG=C #for speed
find . / -printf "%P\n" | sort | uniq -u | xargs rm

And that's just off the top of my head.
Please test it a million times before running.

cheers,
Pádraig.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to