[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mv bug

From: Philip Rowlands
Subject: Re: mv bug
Date: Thu, 8 Dec 2005 04:49:28 +0000 (GMT)

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]