[CentOS] Re: Opposite of cp -u

Stephen Harris lists at spuddy.org
Mon Aug 6 23:50:47 UTC 2007


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

-- 

rgds
Stephen



More information about the CentOS mailing list