I'm looking for a concise way to check if a file was copied using cp -u
.
I have a little shell script which updates quite a number of files. At the moment the script echo
es a little message for each file which gets copied.
Now I want to change the script in such a way that the echo
only gets executed when the file actually was updated. I've checked if cp -u
returned an error code if it didn't copy the file, but this isn't the case.
Is there a better way than manually comparing the timestamps of the files?
Best Answer
Update
Match "->" in cp's verbose output. It only occurs if it could be successfully copied and if your filenames do not contain "->".