How to move all files from current directory to upper directory?

July 9, 2021 . 1 MIN READ

The command you are looking for is

mv * .[^.]* ..

or (see below for more info):

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

Explanation: the mv command moves files and directories. The last argument to mv is the target (in this case the directory one step “up” in the tree, ..). The arguments before that are the source files and directories. The asterisk (*) is a wildcard which matches all files which do not start with a dot. Files that start with a dot (dotfiles) are “hidden”. They are matched using the pattern .[^.]* (see edit below).

See the manpage which I linked for more information on mv.

http://superuser.com/questions/62141/how-to-move-all-files-from-current-directory-to-upper-directory

Leave a Reply

Your email address will not be published. Required fields are marked *