On 05/04/2010 09:09 PM, Gene Heskett wrote: > On Tuesday 04 May 2010, Joćo Victor Martins wrote: >> On Tue, May 04, 2010 at 10:36:19PM -0400, Gene Heskett wrote: >>> I tried to "mv amanda* /home/amanda/*" as root and which >>> which I recall I have done successfully several times before. >> >> The shell expand * _before_ passing the args to mv. So mv saw all >> files starting with 'amanda' and all files (besides . hidden ones) in >> /home/amanda/ as arg. It then picked the last one listed (probably >> /home/amanda/tmp/) as destination. This analysis is correct. >> > I had two files whose names started with amanda in that directory. I would > have assumed it would expand the src pattern of "amanda*" to match only those > two files. And the rest of the files in /home/me, weren't bothered. No > damages to the src directory at all other than removing the files. > > If it expanded that * to include the whole thing, it should have moved the > whole thing. It didn't. In past experience, the target path spec's /* has > always served as just a place holder for the filenames actually selected by > the amanda* in the src spec. Huh? Globbing has never worked like that. Globbing is done by the shell, not by mv, so by the time mv is started, the * has already been converted into one or more filenames. Maybe you are thinking of the rename(1) or mmv(1) utility provided by some distros (but not part of coreutils), where, with proper quoting (so that the * goes through as argv of the rename command, which then does the pattern manipulation you wanted. But mv(1) is specified by POSIX, and has never done pattern manipulation. The glob in your second argument is expanded by the shell independently of the * in the first argument, and mv never knows that either variant was a glob. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org