Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.

share|improve this question
add comment

migrated from stackoverflow.com Aug 24 '11 at 18:17

This question came from our site for professional and enthusiast programmers.

3 Answers

With the folder called 'myfolder' and up one level in the file hierarchy (the point you want it to put) the command would be:

mv myfolder/* .

So for example if the data was in /home/myuser/myfolder then from /home/myuser/ run the command.

share|improve this answer
You may need to also match .* not just * if the archive contained dot-files. Also add ` && rmdir myfolder` to the end o that to remove the now extraneous folder. This is save because it will only run if the mv returns success AND because rmdir will not remove a non-empty directory. –  Caleb Aug 24 '11 at 20:53
Good point on the .*. Removing the original folder is both trivial and not asked for so we'll let OP deal with that him/herself. –  Rudu Aug 24 '11 at 20:57
@Caleb is it possible to write both * and .* in one line? just curiosity –  Richard Nov 13 '12 at 20:40
@Richard Yes, it is. The arguments for mv will all be sources except the LAST argument which needs to be the target for moving (and in the case of multiple sources, needs to be a folder). –  Caleb Nov 13 '12 at 20:50
tested, and it works. –  Richard Nov 16 '12 at 14:39
add comment

mv (directory)/ ../

share|improve this answer
What are the parens supposed to represent here? This looks like it would the directory itself not the contents of the directory like the OP asked. –  Caleb Aug 24 '11 at 20:51
add comment

Here's what worked:

   cp -a /old/dir/* /new/dir/
share|improve this answer
However, this will leave those contents in the old/dir/ as well since this is a copy. –  Dan W Aug 24 '11 at 18:11
This is a copy not a move, and doesn't actually answer your original question (which talked about moving data) –  EightBitTony Aug 24 '11 at 19:40
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.