Recommended VPS Complete list of best VPS hosting providers.

2 cents tip: How to Move All Files and Folders To Upper Directory

Simple Unix command to move all files and folders from current directory to upper directory location – This is another article of my “2 cents tip” edition which is a collection of tiny bitsy tips useful to manage unmanaged server. Sometimes, in certain condition you may need to move all contents (any files with any formats + folders with all its contents + subfolders) of current directory to upper directory. So here it is I will tell you the magic Unix command you can make use of it to do that tricky task. I found the command works when I extracted a Rapidleech zip file which then I got a single folder extracted named “rapidleech” with all its php scripts and folders inside it.

The Magic Command

Here it is my main weapon I use frequently. It works!

mv * .[^.]* ..

Other known commands:

You may also use one of these Unix commands to do the same thing:

(shopt -s dotglob; mv -- * ..)


find . -mindepth 1 -maxdepth 1 -exec mv -t.. -- {} +


mv * .[^.] .??* ..

or this one:

\mv -- * .[^.] .??* ..

The 2 cents:

Why .[^.]* instead of .* ? the pattern .* will also matche . and ... But since you don’t want to (and cannot) move those, it is better to use a pattern which matches any file name starting with a dot except those two. The pattern .[^.]* does just that: it matches any file name starting with a dot followed by a character which is not a dot followed by zero or more arbitrary characters.

And why not using mv * .. instead? Because that command will skip hidden UNIX filenames, those that begin with . (.bashrc) like .htaccess.

Hope you like it.

Add a Comment

Your email address will not be published.

Get more stuff like this
in your inbox

Subscribe and get interesting stuff plus faster updates to your email.