How to use cp -u on a Solaris system which does not support the -u option

cpsolaris

I want to copy only when the SOURCE file is newer than the destination file or when the destination file is missing. As you know, this feature will work on Linux system on following command.

cp -u /source/*.txt /destination/  

but when i am using this command on solaris system 10. Below is my outut:

cp: illegal option -- u
Usage: cp [-f] [-i] [-p] [-@] f1 f2
cp [-f] [-i] [-p] [-@] f1 ... fn d1
cp -r|-R [-H|-L|-P] [-f] [-i] [-p] [-@] d1 ... dn-1 dn 

Is there any solution?

Best Answer

You might use rsync -u which provides the same functionality. It is available on the current Solaris release (11.x) and also in the last Solaris 10 one (Oracle Solaris 10 1/13).

The source code of the Solaris 10 one is included in the full open source code bundle downloadable from here (beware that it's a 1 GB file).

Related Question