A
A
Artyom Innokentiev2015-11-11 17:08:21
linux
Artyom Innokentiev, 2015-11-11 17:08:21

How to merge two folders in Ubuntu 15.10?

The tree is now:

.
 |-- 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

So that after the merge it would look like this:
merged/
 |-- a
 |   |-- file1.txt
 |   |-- file2.txt
 |   |-- file5.txt
 |   `-- file6.txt
 |-- b
 |   |-- file3.txt
 |   |-- file7.txt
 |   `-- file8.txt
 `-- c
     |-- file10.txt
     |-- file4.txt
     `-- file9.txt

How to merge directories dir1 and dir2?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alexxandr, 2015-11-11
@artinnok

cp -r dir2/* dir1/

O
Oleg Tsilyurik, 2015-11-11
@Olej

$ mkdir merged
$ mv dir1 merged
$ mv dir2 merged

You don't even need to specify recursion.

U
Us Feel, 2015-11-14
@FeelUs

cp -r i dir2/* dir1/
you can also add --backup=timestamp
but does anyone know how to do it with mv?
otherwise it constantly swears Directory not empty

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question