0

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 . ../
3
  • 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. Nov 28, 2010 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
    – user9517
    Nov 28, 2010 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, 2010 at 23:21

4 Answers 4

4

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 * ../
3

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

1

This should do:

mv * ../

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

-2

Use rsync. man rsync

2
  • 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, 2010 at 23:18
  • point taken. + 1 for your answer. get the hidden . files.
    – egorgry
    Nov 28, 2010 at 23:31

You must log in to answer this question.

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