Unix Shell - how do I Merge 2 directories?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2006 > how do I Merge 2 directories?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author how do I Merge 2 directories?
bob the builder

2006-01-21, 2:49 am

I have 2 directories with 1000s of files and subdirectories.

there are no doubt some duplicate named files.

I would like to merge the 2 directory structures without clobbering
files with duplicate names.

bob the builder

2006-01-21, 2:49 am

i found some answers finally with google

cp -Riv --reply=no test1/* test0/

i can then clean up the source folder with a dup file finder

the rest of the possible answers are below:
===========================
find dir1 -type f | PERL -lne 'm#([^/]*)/(.*)$#;print "mv -i $1/$2
dir2/$2";'|sh

#!/bin/ksh
for i in `find dir1 -type f`
do
new_folder=` echo $i | sed -e 's/dir1/dir2/' `
echo mv $i $new_folder | sh
done

cd dir1; tar cf - * | (cd ../dir2; tar xvf -)

cp -Rf dir1/* dir2/
rm -f dir1/*

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com