GNU bug report logs -
#6118
[Expert] Bug in mv?
Previous Next
Reported by: Anthony <ant <at> elivefree.net>
Date: Thu, 6 May 2010 00:07:01 UTC
Severity: normal
Merged with 6104
Done: Bob Proulx <bob <at> proulx.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6118 in the body.
You can then email your comments to 6118 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6118
; Package
coreutils
.
(Thu, 06 May 2010 00:07:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Anthony <ant <at> elivefree.net>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Thu, 06 May 2010 00:07:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
>>> 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.
Hi Gene,
As the others say, the behaviour you describe is exactly what one would
expect mv to do with the arguments passed to it.
> 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.
The shell would have expanded two filenames as the first two arguments
(separated by a space) to the mv command.
> 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. That is
> not what it did this time. This time it created a tmp/ directory in
> /home/amanda, moved the whole amanda tree to the tmp directory,
> including the two files I actually asked it to move from
> /home/me/Download. No loss, but a very surprised veteran linux user.
As other posters pointed out /home/amanda/* expands to a listing of
every non-hidden (name doesn't start with a dot) file in /home/amanda.
mv doesn't treat the results of the two wildcard expansions any
differently. It simply always treats the very last argument as the
destination directory. In this case /home/amanda/tmp had already been
created by some other process and just happened to be the last filename
to be expanded by the shell. (Had the last filename been an ordinary
file and not a directory, mv would have given you an error.)
Just to note: /home/amanda/* will expand very differently to
/home/amanda* Most likely /home/amanda* would simply expand to
/home/amanda - unless you have other directories such as /home/amanda.1
or /home/amanda.bak
For my own part when I'm not exactly sure how wildcards will be expanded
in a certain context, I'll substitute "echo" instead of the command
name. e.g. echo amanda* /home/amanda/* would show you what arguments are
being passed to the command.
I also sometimes use the -i option for mv and rm commands so that I'm
prompted yes or no for each file action and I almost always use the -v
option so that I can see what the command is doing as it operates.
Best regards,
Anthony G
Forcibly Merged 6104 6118.
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Thu, 06 May 2010 01:37:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
6104 <at> debbugs.gnu.org and Gene Heskett <gene.heskett <at> gmail.com>
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Thu, 25 Aug 2011 05:30:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 22 Sep 2011 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 326 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.