Advanced merge directory tree with cp in Linux
Posted
by
mtt
on Super User
See other posts from Super User
or by mtt
Published on 2012-10-14T20:29:42Z
Indexed on
2012/10/14
21:40 UTC
Read the original article
Hit count: 262
I need to:
Copy all of a tree's folders (with all files, including hidden) under
/sourcefolder/*
preserving user privileges to/destfolder/
If there is a conflict with a file (a file with the same name exists in
destfolder
), then- rename file in destfolder with a standard rule, like add "old" prefix to filename (readme.txt will become oldreadme.txt)
- copy the conflicted file from source to destination
Conflicts between folders should be transparent - if same directory exists in both sourcefolder and destfolder, then preserve it and recursively copy its content according to the above rules.
I need also a .txt report that describes all files/folders added to destfolder and files that were renamed.
How can I accomplish this?
© Super User or respective owner