I have two directory trees with similar layouts, i.e.
.
|-- dir1
| |-- a
| | |-- file1.txt
| | `-- file2.txt
| |-- b
| | `-- file3.txt
| `-- c
| `-- file4.txt
`-- dir2
|-- a
| |-- file5.txt
| `-- file6.txt
|-- b
| |-- file7.txt
| `-- file8.txt
`-- c
|-- file10.txt
`-- file9.txt
I would like to merge the the dir1 and dir2 directory trees to create:
merged/
|-- a
| |-- file1.txt
| |-- file2.txt
| |-- file5.txt
| `-- file6.txt
|-- b
| |-- file3.txt
| |-- file7.txt
| `-- file8.txt
`-- c
|-- file10.txt
|-- file4.txt
`-- file9.txt
I know that I can do this using the "cp" command, but I want to move the files instead of copying, because the actual directories I want to merge are really large and contain lots of files (millions). If I use "mv" I get the "File exists" error because of conflicting directory names.
UPDATE: You can assume that there are no duplicate files between the two directory trees.