FBSD equivalent to Linux cp -u

Lowell Gilbert freebsd-questions-local at be-well.no-ip.com
Fri Sep 5 20:10:56 PDT 2003


"Charles Howse" <chowse at charter.net> writes:

> I have read man cp, and I don't see a way to copy source file to
> destination file *only* if source file is newer than destination file.
> 
> In Linux, I could do cp -u.  Is there another utility that can pull this
> off?

In sh(1), it should be as simple as:

 if [ $sourcefile -nt $destinationfile ] ; 
  then 
    cp -p $sourcefile $destinationfile ; 
 fi

[untested]


More information about the freebsd-questions mailing list