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?

chicks
  • 3,793
  • 10
  • 27
  • 36
Blankman
  • 2,891
  • 10
  • 39
  • 68

4 Answers4

18

shorter version:

mv folder2/* .
panaroik
  • 832
  • 5
  • 12
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.

Art Shayderov
  • 246
  • 2
  • 8
0

recursively move files to current folder:

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

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

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