Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
mv is move.it is for moving a file to another location.fine??
so 'mv *.jpg /blahblah' will move every .jpg stuff to /blahblah',with the same name.you cant move all the files to another file.but moving a single file abc.jpg to bbc.jpg is possible.but 'mv *.jpg /blahblah/* wont work.i guess you got it.
Originally posted by oopicmaster IMHO it is a dumb way to do things.
Why should a command behave differently just because It needs to operate on more that one file?
Dont you find that to be just a wee bit.... kooky?
mv is not meant for renaming files. It was made to move them If you want to rename files then get ren like Col Panic said. ren is far superior to the MS-DOS (and hence windows) move command anyway, with MS-DOS a typo can mean all your files disappear into one file. Surely you've done that before, I certainly have.
... from the ren man page:
" The multiple rename is performed
safely, i.e. without any unexpected deletion of files due
to collisions of replacement names with existing names, or
with other replacement names. Also, all error checking is
done prior to doing any renames, so either all renames are
done, or none."
Coolness, and it's free
you can get it from here too, if you haven't tried it already that is...
# by Micxz [at] hotmail.com
if [ -z "$NAME2" ]; then
echo 'You must export a name to rename files first (eg. "export NAME2=RENAMETO")'
for x in *; do
echo -n $x;
echo -ne '\000'
echo -n `echo $x | cut -f 1 -d '.'`
echo -n "$NAME2."
echo -n `echo $x | cut -f 2- -d '.'`;
echo -ne '\000'
done | xargs -0 -n2 mv
Be careful if you don't understand what this script is doing then maybe you should not be running it.
Your building a list of the filenames followed by the name we want to mv it to. seperated by NULL characters in the current directory. Then we feed the entire list to xargs witht the switchs to let mv have two arguments
this would be the hard way. As the others mentioned "rename" does the same;
oopicmaster should know that ALL major operating systems are extentions/follower of UNIX. dos commands are nothing but variations of unix commands. so anything u do in windows especially in command prompt, can be done a hundred times better in linux/unix. please don't make me laugh saying that u can do more in command prompt in windows than in linux. LOL again
mv is not meant for renaming files. It was made to move them
Yes but at the single file level it allows you to move a file from one filename to another.
It would be simple, and much more intuitive if the command worked the same way for multiple files.
It should only allow you to move SINGLE files to a directory as well. Changing behaviour between single vs. multiple is IMHO inconsistent and poor design
oopicmaster should know that ALL major operating systems are extentions/follower of UNIX.
Yes they took UNIX and made it better, and easier to understand, thats why other OS's have dominated the PC market.
IMHO the mv command shouldnt exist at all!
Moving a file should just be a switch on the copy command! Moving is just copying where you delete the source file after copying. I shouldnt need 2 completely different commands for that.
Its just like the rm and rmdir commands... complete waste... especially when rm -rf can remove a directory too! Its like the designers of Unix had nothing better to do than make up a bunch of extra commands.
why do you folks waste your time responding to an obvious troll? plenty of people could use your expertise for help with actual problems. if he can't man or figure out simple mv or ren commands, let him go back to windows, "where everything is better and intuitive."
Originally posted by motub Because you never know when a new user who's "on the fence" might read this thread, and have the same questions.
I'm sure that none of us think that we're going to "convince" the troll, but you've got to think of the future generations of Linux users
i'm thinking about the current generation who need actual help. and i doubt a thread about moving files is going to convince anyone one way or another about whether they should use linux (at least it shouldn't).
Actually if you want to get specific about the comparison between cp and mv commands, the way mv writes, i dont think that the file is actually copied from one location to another, and then deleted. the data isnt actually moved around on disk unless you move it to /usr/local, or another partition that you have set up besides your root one. it has more to do with where the file points to on disk, and not just that its in a different directory....hence why you need to defrag once in a while