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.
You can do this fairly easily using the rename program which comes with perl. The syntax is a little mysterious if you don't understand perl regular expressions, so it might be a good idea to read about them before using it.
This command just shows what will be renamed to what without actually doing it - good to check that it's the right thing...
The rename command is part of util-linux, not perl, at least on Slackware.
Also, you don't need to match the whole thing, only the part you want to change, e.g.
Code:
rename xx bh data*
should suffice.
Excellent, didn't know that one. Thanks. It's author of rename is Larry Wall. I had assumed it came with perl. In Ubuntu Edgy, dpkg claims not to know which package owns this file, which is a little annoying. Ho hum.
Excellent, didn't know that one. Thanks. It's author of rename is Larry Wall. I had assumed it came with perl. In Ubuntu Edgy, dpkg claims not to know which package owns this file, which is a little annoying. Ho hum.
Ah, I didn't know LW wrote rename. The Slack man page is pretty minimal. It's possible it was supplied with perl originally. util-linux has sucked up loads of handy utilities into one package, just as core-utils unified sh-utils and a few other packages I can't remember the name of. I did a quick google for a history of rename but couldn't find anything of much interest.
And, yeah, rename only changes the pattern specified, the rest of the filename is unchanged. It took me a while to get my head around this, since it's completely different to every other "rename" command on various OSes and to sed etc. Dead handy command, though, and very easy to use once you grok it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.