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!
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.
youre' joking right??? why on earth would you bother with a contrived regex when you can just count to 41???
Well, I typed the regex in 5 or 6 seconds, which is less time it takes to count characters on a screen. I suppose you could 'ls -1 *' into a file and use a text editor to display the character offsets, but that would still take longer than typing a perl one-liner. At least, for people familiar with typing perl one-liners.
First hit on google: Norris McWhirter, co-founder of the Guinness Book of Records,
Ah, cheers. Too lazy to google last night...
Back on topic, another point is that a regex is more general. If, next week, the OP has some similar files to rename that are a few characters longer or shorter, a pattern will still work, but hard-coded values will need to be recounted.
Perhaps the primary advantage of the perl method is that only 1 program is spawned. With the other methods (admittedly, including zsh's zmv), an instance of mv is spawned for each file. For a few dozen, or even a hundred or so, files this is no big deal, but if the OP has 10,000 files to rename, it becomes a significant factor.
My feeling is that my computers exist to do the laborious work for me. I didn't spend hundreds of pounds on all this fancy electronic equipment just I could sit in front of it counting characters on a screen. Better to exercise those regex skills.
Your main argument, acid_kewpie, seems to be that the main goal is simplicity. But it is not so! The main goal (for me, anyway) is elegence. Certainly, simplicity is a large factor in elegence, but as Einstein said, things should be "as simple as possible, but no simpler". Manually counting characters is just a little too simple, IMO.
nah, you're just totally missing the point. a dude wanted to achieve a specific task. the very simplest way i could imagine is to use cut. you'd cover tools like cut at about, hour 3 of "learning unix" you wouldn't get on to regular expressions till, oooh, hour 10 i reckon. what use is an "elegant" solution if the OP doesn't understand it (which may or may not be the case). you can't learn from it if you've no idea at all what it's all about. do you not relasie how horrible regular expressions are to a newbie?
Well, OK, but if you achieve a specific task, all you've done is achieve a specific task. Regular expressions open the door to further possibilities, isn't that part of what LQ is about? Yes, your original solution solved the immediate problem, simply and succinctly, as the OP ackowledged. The following posts are just looking at "other ways", and the OP is free to explore those at his/her leisure, or not.
do you not relasie how horrible regular expressions are to a newbie?
Nope. I found them fascinating from the first moment I saw one. Maybe I should get out more?
of course regular expressions are more useful, but only if you understand them enough to benefit from them. if you don't understand regular expressions and have a problem you need to fix somehow, anyhow, then you're going to be more inclined to use an alternative method than to go off and learn about regular expressions for 5 hours. sure it's good to know they exist, but more often than not it's about solving the problem in hand, not so much the learning. and it's still chuffing useful to learn ho to use cut anyway.
Since when were fascinating and horrible mutually exclusive? you don't think erm... Jordan and Peter Andre are fascinating? OK bad example...