3

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?

rtacconi
  • 745
  • 4
  • 14
  • 28
  • are you expecting the change date to be the current time or the time of the source files? The date should match that of the source files since they are being copied. Since the files themselves are not being modified the date will not be changed to the current time. – einstiien Feb 15 '10 at 16:32

1 Answers1

2

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/
Pablo Martinez
  • 2,406
  • 17
  • 13
  • diff source_dir/ dest_dir/ did the job. I still wondering why cp does not update the changed date when overwriting a file. On Solaris 10 I have not found any -n option. – rtacconi Feb 15 '10 at 11:22