Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my server, I am in the folder:

/path/to/www/some_folder/

Now I want to move all the contents of this folder to the parent folder i.e. www

What should I do?

Will this work:

/path/to/www/some_folder/mv -R . ../
share|improve this question
    
I don't know linux syntax well, but your command should be before the paths... so mv -r . ../ why not create few directories and files yourself using the touch command and figure out the behavior? thats how i learned to use TAR correctly. –  SpacemanSpiff Nov 28 '10 at 23:01
    
mv doesn't have a -R option. When I try this (without -the -R) I get mv: cannot move .' to ../.': Device or resource busy –  Iain Nov 28 '10 at 23:05
1  
There is one interesting edge case here which is when there is a some_folder/some_folder, in which case many of the mv commands will fail; probably the simplest case there is to rename the directory first. –  poolie Nov 28 '10 at 23:21
add comment

4 Answers

up vote 4 down vote accepted

mv * ../ is almost enough, unless there are dotfiles that you also need to move, and in a www directory there might well be for example .htaccess files.

So you want something like

mv * .[^.]* ../

or in zsh, which is nice enough to not expand .* to .., you have

mv * .* ../

or

setopt globdots
mv * ../
share|improve this answer
add comment

If you try a simple mv * .. it should work.

share|improve this answer
add comment

This should do:

mv * ../

Because of the way mv works, you will not need the recursive option.

share|improve this answer
add comment

Use rsync. man rsync

share|improve this answer
    
rsync is not a great option here because, firstly, it copies the files rather than moving them, which will be slower and more likely to cause trouble if any files are open, and also it will leave a copy of the files behind. –  poolie Nov 28 '10 at 23:18
    
point taken. + 1 for your answer. get the hidden . files. –  egorgry Nov 28 '10 at 23:31
add comment

Your Answer

 
discard

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

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