Cp -R source_dir/* dest_dir/ does overwrite files

cplsunix

I am trying to copy, recursively, the content of a directory to another using:

cp -Rv source_dir/* dest_dir/

It seems that everything work ok but when I list that directory with ls -l the change data it is not updated to the current time. So, how can I be sure that my command has overwritten the old files?

Best Answer

If you are not sure, check that you are not running cp as an alias (from your shell type "alias cp"), if you don't have additional parameters (specially -n) cp -R will overwrite the files in desti_dir unless you have an issue with permissions.

But if you need to be sure, you can run diff to compare both directories

diff source_dir/ dest_dir/
Related Topic