I know each part of this command.
sudo mv home/* *
sudo
: super-user do, execute with root privileges.mv
: move a file or directory.home/*
: argument of mv command. It indicates the content of home directory. The asterisk *
is a wildcard that expands to the list of files in the current directory in lexicographic order.The next argument is the destiny folder. However, I specify an asterisk as destiny directory, and if I execute the command the folder disappear completely. So, what does the *
in this case?
Let's say you have /home/userA
, /home/userB
and /home/userC
. Let's further say you're running this in a directory that contains 1.txt
, 2.txt
, and a directory 3.d
.
Under those circumstances, this would expand to:
sudo mv /home/userA /home/userB /home/userC 1.txt 2.txt 3.d
That is to say, both globs are expanded -- the first to the list of entries in /home
, an the subject to the list of files in the current working directory -- and the result is everything being moved into the directory 3.d
.
Flagged Community Wiki since this is an answer to an off-topic question.