[Ilugc] Re: how to merge directory contents

  • From: dearsaravanan@xxxxxxxxx (Saravanan S)
  • Date: Tue Jan 19 19:21:29 2010

Hi Sriram,

On Tue, Jan 19, 2010 at 6:02 PM, P.Sriram <sriram@xxxxxxxxxxxxx> wrote:

Saravanan S <dearsaravanan@...> writes:

      I need to merge the contents of several directories, into a single
directory structure,
Like i have
dir1/a/1
dir1/b/2
dir2/a/10
dir2/b/20

after merging dir1 and dir2, i should get,

dirnew/a/1 and 10
dirnew/b/2 and 20

How to do this easily?

Well, I cant believe this is still left unsolved. So, here is a (tried and
tested) suggestion. How about using the -u option of the cp command? Like
this,

cp -r dir1/* dirnew
cp -r -u dir2/* dirnew

If the * expansion dies because of the number of files, then you may have
to
write a short script with the same logic.


Thanks for the timely guidance. :) Will check this out!!!

--
Saravanan Sundaramoorthy
Red Hat Certified Engineer
+91 99404 32545

Other related posts: