bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can you please add a synchronization feature to the GNU cp


From: Pádraig Brady
Subject: Re: can you please add a synchronization feature to the GNU cp
Date: Wed, 11 Jun 2008 20:20:42 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]