2

How in Linux using cp one can copy file to destination, but if destination exists, then overwrite only if destination is older than source?

cp -f always overwrites, but overwrite is needed only if target is older than source.

0

1 Answer 1

5
cp -u

According to the cp man page, -u will only overwrite file if the destination is older than the source.

It appears the -u option is not available for scp, so if you need to do it on a remote host, use rsync. By default, rsync skips files that have the same size, name, and last modified time. Rsync also has a -u option to skip destination files that are newer.

Not the answer you're looking for? Browse other questions tagged .