10

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?

4 Answers 4

18

shorter version:

mv folder2/* .
3

mv /folder1/folder2/* /folder1/

3

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.

0

recursively move files to current folder:

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

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

2
  • You should have explained how that will behave differently from the earlier answers and in what circumstances that would be desirable.
    – kasperd
    Nov 1, 2017 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, 2017 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .