On Wed, 7 Dec 2005, Vincent Chan wrote:

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:

$ echo a.*
a.avi a.rar
$ mv --verbose a.*
`a.avi' -> `a.rar'

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


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to