Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
I have a batch of files that have the following pattern:
[variable length name] # ABC.ABC
[variable length name] can be anything, that need to remain unchanged.
I need to mass rename all of these files to remove the " # ABC" portion.
I've been trying to work with perl expressions but guess I haven't gotten it right. Could use some help.
Here are some of the patterns I've tried:
# rename 's/ # ABC\.ABC$/\.ABC/ *.ABC'
# rename 's/. # ABC$/ /' *.ABC
... and a various other attempts.
PS - If you're using Bash4 (I don't know if 3.x can do it) you can do this without the sed, just by using shell variable substitution; I haven't played with that much yet (I'm stuck in my ways) so didn't suggest it; other members are more versed in the newer shell features and can give you better advice on that when they come around (or you can check out the bash man page).
(I'm replying with my cell, so grammar may be problematic.)
I am using 'rename'. I cited examples in my first post, but here are more filename examples:
My file # 123.ABC
Your file # 123.ABC
Note the ' # 123' is what I need to remove. I need to keep the .ABC at the end.
At least you got what you needed accomplished by whichever means.
Honestly, I should look into simpler means of doing things sometimes -- but what the heck, the more ways we have to choose from, the better!
P.S> there was another thread within the last few weeks, where someone was trying to use `rename` and it became apparent that `rename` may or may not exist on some machines, and may or may not be the SAME `rename` as it is on other machines. Just something to keep in mind, in case it one day doesn't work on some machine you happen to be using.
Last edited by GrapefruiTgirl; 03-16-2010 at 04:21 PM.