3
Directory A and B have many subdirectories with nearly identical content. Directory B may have newer files and some subdirectories that directory A does not have. When files in Directory B are newer, I want those to overwrite the ones in A. When B contains subdirectories that A does not have, I want B directories to be merged into the results. So, I guess all I'm saying is I need to merge two directories using commands available on Solaris and OSX. I'm working locally on OSX, but will need to perform the same procedure on a Solaris box. I've found a couple of techniques. The first approach is to use tar:
cd A tar -cvf content.tar * cp content.tar ../B tar -uvf content.tar * cp content.tar ../ mv A A_backup; mv B B_backup tar -xvf content.tar
(Wow! that seems messy)
Another approach:
cd B tar cf - . |(cd ../A; tar xvf -)
(That merges everything into A)
The problem I have with both is perhaps mostly a confidence issue. I'm not familiar with the methods and can't really see what is happening. I can't see what files were overwritten or what folders or files existed in B that did not exist in A.
Is there a better way?
1If you don't require using same tool on both systems, consider making this two questions. – Daniel Beck – 2011-06-01T14:07:20.133