Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
* = 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.