0

I have two directories with the following structure:

A
|_0
|_1
|_2

B
|_0
|_1
|_2

each 0,1,2 directory contains unique contents. I want all of the contents to simply exist as:

A
|_0
|_1
|_2

Is there a one liner for this? This is simplified, as the directory structure is about 4 layers deep with 16 directories per level...so it's huge.

3
  • Is this a temporary merge, or permanent? If temporary, you could use something like unionfs perhaps? – Zoredache Apr 9 '14 at 19:54
  • 1
    By "unique contents" do you mean all the files in A have different names than in B? If so, a simple recursive copy will suffice, as in: superuser.com/questions/242638/… – coneslayer Apr 9 '14 at 19:59
  • Unfortunately I just realized that the files may have the same names, but they certainly have different contents. – Evan Apr 9 '14 at 20:04
0

Given enough space, I would copy A to C, then B to C.

mkdir C
cp -rp A/* C
cp -rp B/* C
1
  • Hmmm, the files may have the same name, and If I had fileA and fileA I'd like to have both (perhaps, fileA and fileA.1 or something) – Evan Apr 9 '14 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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