I have directory a and directory b. They are big. b is almost identical to a. "almost" means that 4-5 files differ, and I don't know which they are. I want to copy b over a, but only the files that differ. i'm in bash.

(no, I can't simply delete a and replace it with b, because 1) a is version-controlled 2) a full copy (or a mv) would take too much. I want to copy only the files that differ).

link|improve this question
Is rsync an option? – Bobby Feb 3 '11 at 11:43
It is, but I don't know much about rsync. – janesconference Feb 3 '11 at 11:44
feedback

4 Answers

up vote 5 down vote accepted

You can use rsync to do this, the command I use is rsync -tr "folder to copy from" "folder to copy to"

e.g. rsync -tr /home/me/stuff/* /home/me/otherstuff/

link|improve this answer
feedback

It is also possible to do this with good old cp:

cp -ru old-dir new-dir

link|improve this answer
+1 I get so used to synching across machines I forget the elegant ways. – Tog Feb 3 '11 at 12:11
does not work for me :( – janesconference Feb 3 '11 at 12:51
That's actually good gnu cp. ;-) – Keith Feb 3 '11 at 19:58
feedback

Another good option is Unison (http://www.cis.upenn.edu/~bcpierce/unison/), particularly if there isn't really a "source" and a "destination". Each directory is a root and Unison syncs them and keeps metadata for future syncs. It offers both a command-line and a GUI option that can easily be scheduled via cron as well.

I use it to make a backup of my Dropbox to my local NAS appliance which can't run a Dropbox client.

link|improve this answer
feedback

"diff -r a b" would give you the difference in files( not the content )

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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