coreutils
[Top][All Lists]
Advanced

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

Re: mv * command


From: Eric Blake
Subject: Re: mv * command
Date: Mon, 20 Jun 2011 10:58:42 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 06/20/2011 08:21 AM, Susanto Wijaya wrote:
> May I ask question about mv * command?

Are you talking about a literal:

$ mv *

typed on the command line?  To see what this really did, try:

$ echo mv *

and notice how the shell expands every existing file name in the current
directory before ever calling mv.  Therefore, mv sees the last expanded
argument as the name of the directory to move files into (assuming the
last file named happens to be a directory)...

> 
> 
> The question is when I use mv filename command using normal user login, the
> result is all files and directory will lost except might be 1 folder

which explains why doing this in your home directory moves all other
files into the last-named directory, per the 'mv [OPTION]... SOURCE...
DIRECTORY' synopsis form.

> 
> If I use mv * command using root user in root directory "/", the result is
> all files and directory in / root directory will gone.

Well, yeah, insofar as possible (the operation may abort a bit early
depending on whether you moved something critical to the success of the
continued operation of mv).  But this is not a bug in mv, so much as the
power of Unix to let you shoot yourself in the foot if you type a stupid
command as root.

> 
> Is all directory and files move to /dev/null ?

No, they are all moved to the last directory specified by your command line.

> 
> Now all my files in home directory is lost after run the mv * command

Not lost, but moved.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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