Command MV */*
What will command MV */* do exactly.
MV is for move, but the asterisk in this case does what?
but "mv */*" is not a valid command: there are too few arguments.
* = 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.)
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.
|All times are GMT -5. The time now is 07:54 PM.|