LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-02-2011, 09:31 AM   #1
numlock01
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
Command MV */*


What will command MV */* do exactly.

MV is for move, but the asterisk in this case does what?

Thanks
 
Old 03-02-2011, 10:21 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
http://tldp.org/LDP/abs/html/globbingref.html

but "mv */*" is not a valid command: there are too few arguments.
 
Old 03-02-2011, 11:06 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
* = match all characters
? = match a single character

So */* implies you are moving all files in all directories below the one you were sitting in when you executed the command.

However the "mv" command requires a target not just a source - typing "mv */*" ideally would do nothing - worse it might try to expand so that the first file it finds is moved to the second one (thereby overwriting it).

Also it is NOT "MV" it is "mv". Linux is case sensitive which means MV, mV, Mv, and mv are all different. By default Linux will have "mv" for (move which is also used to rename) but not MV, mV, or Mv - however if you happened to have something by the name MV in your PATH it would execute that instead of the "mv" command you intended.

To mv multiple files it is best to do something like:

mv $(*/*) <newdir>
That would move all the files in subdirectories of the current directory into whatever directory you specified. (The new directory would need to extist first.)
e.g.
mv $(*/*) /testdir
Would move the files into /testdir (assuming it existed - otherwise it might try to rename each file to "/testdir" so that only the last file in your list actually was there - since it is mv your originals would all be gone.

Using "*" in commands like mv and rm should be done carefully because you can end up blowing away lots of files without meaning to do so. For example since "*" doesn't match dot files (e.g. .bashrc, .bash_profile, .mozilla) many a user has made the mistake of doing something like "rm .*" to try to remove those files. This is a problem because every UNIX/Linux directory should have an entry called ".." which is a link the parent directory. Since ".." would be matched by ".*" the rm command would actually remove the parent directory's files rather than the just the dot files in the current directory.
 
1 members found this post helpful.
Old 03-10-2011, 04:28 AM   #4
numlock01
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks guys
 
  


Reply

Tags
shell



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration