I have a bunched of files in a directory and there are a.avi and a.rar
in it. Inside the directory, there is also a directory called "a". I
wanted to type "mv a.* a". But instead I typed "mv a.*" by mistake. As
a result, I can't find the original a.rar anymore, but I found that it
renamed a.avi to a.rar. Why?
This behaviour is caused not by mv itself, but the actions of the shell
expanding the "a.*" argument. Permit me to explain by example:
The shell passes the two separate filenames to mv, which interprets the
arguments as a request to overwrite. To avoid this, you could create a
shell alias such as:
alias mv='mv -i'
which will prompt the user in situations like this.
Cheers,
Phil