Shell Command – How to Move and Overwrite Subdirectories to Parent Directory

command linefilesshell

I have a ton of files and dirs in a subdirectory I want to move to the parent directory. There are already some files and dirs in the target directory which need to be overwritten. Files that are only present in the target should be left untouched. Can I force mvto do that? It (mv * ..) complains

mv: cannot move `xyz' to `../xyz': Directory not empty

What am I missing?

Best Answer

You will have to copy them to the destination and then delete the source, using the commands cp -r * .. followed by rm -rf *.

I don't think you can "merge" directories using mv.

Related Question