Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 Answer 1

up vote 2 down vote accepted

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/
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.