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?
if [ "$src" -nt "$dst ]; then …
construct you can use that one (however, not it's not in POSIX). Do you havepax
orrsync
available? That might be the easiest solution. – Marco Jan 27 '16 at 09:55filesync
? See https://docs.oracle.com/cd/E23823_01/html/816-5165/filesync-1.html#scrolltoc – Andrew Henle Jan 27 '16 at 17:54