Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

Your Answer


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.