Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have installed wordpress onto my CentOS server.

Now inside my /var/ww/html folder, I have a wordpress folder. I want to move all the files inside the 'wordpress' folder up into the parent dir, which is /var/www/html.

Now I have read this post - Linux: How to move all files from current directory to upper directory?

and I have tried the commands suggested there, and all that command line is saying is:

[root@servername wordpress]# mv * .[^.]* ..
mv: cannot stat `*': No such file or directory

How do I move all the files up one dir?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

If you have bash 4+ (check with bash --version), you can simply use the dotglob shell option to ensure that globs include files starting with . by default.

shopt -s dotglob ## activate dotglob
mv ./* ../
shopt -u dotglob ## deactivate dotglob

Aside from reducing the amount of thinking you need to give to this task, it also has the advantage of being smart enough to not match . and .. without you having to mess around. I prefer to preface my globs with ./ to prevent any filenames beginning with a - from being treated as options.

However, your error indicates to me that you're trying to work on an empty directory, or at least one that only contains dotfiles. By default, if a glob doesn't match any filenames, bash sends it literally to the command -- and since there is no file named * in the directory, mv is sending that error.

share|improve this answer
    
cool...I got it sorted thank you. For some reason it actually moved the files, amongst all the errors I got. But thank you for the tip –  DextrousDave Jul 6 '13 at 12:58
1  
You may also find this page useful for future reference (that whole website is a very good reference for working with bash). –  evilsoup Jul 6 '13 at 13:04
add comment

The message indicates that there is no files matching '*'. Make sure that there exists files or folders in the folder you're moving from. If only files or folders starting with . exists you can run the command mv .[^.]* .. to move them one directory up. Verify that all files are moved by running ls -la and verify that the list only contains this (.) and above (..) directories.

share|improve this answer
    
OK cool thank you Mattias –  DextrousDave Jul 6 '13 at 13:30
add comment

As others have said, you are probably running your command on an empty directory. Another way of doing this (that will simply fail silently on an empty directory) is to use find's -exec action:

find . -exec mv '{}' ../ \;

This will give you an error:

mv: cannot move `./' to `../.': Device or resource busy

This is because I am not restricting find by file type so it will also attempt to move the current directory (.) and fail. You can safely ignore this error, or you can specify you want all types of files and folders:

find . \( -type f -o -type d \)   -exec echo '{}' ../ \;

From man find:

  -exec command ;
          Execute command; true if 0 status is returned.
          All following arguments to find are  taken  to
          be  arguments to the command until an argument
          consisting of `;' is encountered.  The  string
          `{}'  is  replaced  by  the  current file name
          being processed everywhere it  occurs  in  the
          arguments  to  the  command, not just in argu‐
          ments where it is alone, as in  some  versions
          of  find.   Both  of these constructions might
          need to be escaped (with a `\') or  quoted  to
          protect them from expansion by the shell. 
share|improve this answer
    
cool thank you for your answer –  DextrousDave Jul 6 '13 at 16:48
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.