How to use cp -u to only copy if content is different, it fails when doing as below
$ cd /tmp/exper ; cp -v ~/Downloads/C/test.c . ; sudo chmod -R 777 .
/home/budi/Downloads/C/test.c -> 'test.c'
$ cp -v -u test.c ~/Downloads/C
'test.c' -> '/home/budi/Downloads/C/test.c
as content is the same but through sudo chmod -R 777 .
How to do this correctly?
rsyncinstead ofcp.rsynchas a lot more features, it is well described in the manual, and you can easily get help here or read tutorials via the internet. Please notice thatrsyncis not only targeting remote copying of files, it works well locally between different locations in a computer.