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 have 2 folders , A and B. they are similar, but there are some files in A that are not present in B. what's the best way to copy only the new files in A into B, without changing the existing files in B?

share|improve this question
add comment

2 Answers

You can also:

cd A
find . -print | cpio -pd ../B/

Or you can:

cd A
rsync -a --update . ../B/

And you can probably do something similar wth tar.

share|improve this answer
    
With rsync you'd want --ignore-existing if you don't want to replace the files that have the same names but different contents. –  DerfK Nov 20 '10 at 4:26
add comment

cp with -n.

share|improve this answer
    
This is there on my Ubuntu system, but man cp on my Centos 5.5 system seems to be missing it. –  ehsanul Nov 19 '10 at 23:59
add comment

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.