Say my files on a Ubuntu server are like: /folder1/folder2/

I am in folder1 currently, and I want to move all files/folders (recursive) from folder2 to the current folder.

How can I do this?


shorter version:

mv folder2/* .

mv /folder1/folder2/* /folder1/


there is a caveat to be aware of if you have invisible files (starting with '.') in your folder. dotglob (*) won't expand (and mv won't move) invisible files unless you change it's behaviour with shopt. shopt -s dotglob to expand invisible files and shopt -u dotglob to switch back to default.


recursively move files to current folder:

find -type f -exec mv -v {} . \;

be aware that you won't be overwriting existing files.

  • You should have explained how that will behave differently from the earlier answers and in what circumstances that would be desirable.
    – kasperd
    Nov 1 '17 at 7:44
  • For instance, this would work when there are more files than can fit into one shell command. Or you're in a shell that doesn't support globbing.
    – chicks
    Nov 1 '17 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.