only practical “workaround” so far: https://dwaves.de/2015/05/26/linux-simple-local-rsync-example/
(its not really a solution)
there should be a simple command like merge/integrate:
[cc lang=”bash” escaped=”true” width=”500″]
merge /path/A /path/B; # merges all files from A into B, creating directories but NEVER (!) deleting target directories or files
[/cc]
how do i test it?
[cc lang=”bash” escaped=”true” width=”500″]
mkdir A B; # create
cd A;
touch 1 2 3;
mkdir KEEPCONTENT;
cd KEEPCONTENT;
touch 1 2 3;
cd ../../B;
touch 4 5 6;
mkdir KEEPCONTENT;
cd KEEPCONTENT;
touch 4 5 6;
merge A B; # merge the two folders
ls -lah /B; # expected result:
1 2 3 4 5 6
ls -lah /B/KEEPCONTENT; # expected result:
1 2 3 4 5 6
[/cc]
you MIGHT think you can do this like that:
[cc lang=”bash” escaped=”true” width=”500″]
mv -v ./A/* ./B/
[/cc]
but the MAJOR problem with current implementation of mv is that if you have a two subdirs /B/KEEPCONTENT and a dir /A/KEEPCONTENT and you do a mv A B you likey get /B/KEEPCONTENT overwritten/deleted in fact loosing data.
[cc lang=”bash” escaped=”true” width=”500″]
mv -v ./A/* ./B/
‘./A/4’ -> ‘./B/4’
‘./A/5’ -> ‘./B/5’
‘./A/6’ -> ‘./B/6’
mv: overwrite ‘./B/KEEPCONTENT’?
[/cc]
this is rather uncomfortable.
know what i mean? 😀
c’mon guys. ASAP = As Simple As Possible = no fiddeling with scripts/hacker skills needed to merge two dirs = cleaning ladies should be capable of doing such “complicated” things in the 21st century.
yes i could use rsync… but rsync does not “MOVE” it only “COPIES”.
so we are f****ed or we learn GNU C and do it ourselves or we spend 3.5 days testing scripts.
not good – we can do better 🙂
links:
http://superuser.com/questions/656301/bash-merge-directories-when-using-mv
http://unix.stackexchange.com/questions/127712/merging-folders-with-mv
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!