Copy files in Linux, avoid the copy if files do exist in destination
cp -R -u -p /source /destination
The -u
(or --update
) flag does just this:
From the man page for cp:
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing
Just use cp -n <source> <dest>
.
From man page:
-n, --no-clobber
do NOT overwrite an existing file (overrides a previous -i option)
rsync -aq /src /dest
Apart from only copying newer files, it will even only copy the newer parts of files if the file has changed. It's intended for copying over network links where you want to minimise the amount of data - but it also works great locally.
Look up the "-u" option for the cp
command.