[CentOS] Re: Opposite of cp -u
Robert Nichols
rnicholsNOSPAM at comcast.net
Tue Aug 7 01:19:09 UTC 2007
Stephen Harris wrote:
> On Mon, Aug 06, 2007 at 06:27:20PM -0500, Robert Nichols wrote:
>> for F in *
>> do cmp "$F" "/new/directory/$F" && touch -r "$F" "/new/directory/$F"
>> done
>>
>> That will compare all the files and adjust the timestamp on the files
>> that are still the same as those on the backup. Note that, despite
>> the quoting, the script will break if any of the filenames have embedded
>> whitespace because the "for F in *" will be parsed incorrectly.
>
> Not in a sane shell. Heh, not even in bash :-)
>
> bash-2.05b$ touch "a b"
> bash-2.05b$ touch c
> bash-2.05b$ touch d
> bash-2.05b$ ls
> a b c d
> bash-2.05b$ for a in *
> > do
> > echo Result is: $a
> > done
> Result is: a b
> Result is: c
> Result is: d
OK. Color me paranoid, or maybe "once burned, twice shy."
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.
More information about the CentOS
mailing list