How to move content of a folder to current folder?

mv will overwrite files, but it will refuse to overwrite directories. There's no single command that will merge directories and remove the source directories (which is probably what you want with mv). Even rsync --remove-source-files will leave empty directories.

You can use a combination of commands:

cp -a dev/. .
rm -r dev

which copies everything in dev to the current directory and then removes the dev directory.

Or:

rsync -a --remove-source-files dev/ .
find dev -depth -type d -exec rmdir {} \;

which uses rsync to move all the files, and then deletes the empty directories left behind.


Issue at Hand

You wish to move the contents of foo/bar/ up a level to foo/.

I will be referencing this post on superuser as well as this post from serverfault in the solution.

Solution

According to user Stephan202, you are looking for the following commands to execute this task:

cd /path/to/foo/bar
mv * .[^.]* ..

It should also be possible, from within foo/bar/, to run the following command as well:

(shopt -s dotglob; mv -- * ..)

Verify you have the correct permissions as well. If needed run the command with root(sudo) privileges.

Conclusion

Please comment if you have any questions or issues with this answer. I highly suggest you read through each link I have provided thoroughly before attempting the commands. I appreciate feedback to correct any misconceptions and to improve my posts. I can update my answer as needed.

Best of Luck!

Tags:

Mv

Cp