Find several different words and replace with one using sed.
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.
Find several different words and replace with one using sed.
So as my title says, im trying to match multiple words and replace them all with one.
I have tried "test|just|this" in my regex checker app and it matches all 3 words, but when I try use it in the sed command it doesn't match any...
What am I doing wrong here?
Code:
echo This is just quick little test | sed 's/test|just|this/./i'
I know I could just make several sed commands for each word but that seems messy and not conventional.
I would appreciate some help here.
Last edited by Techno Guy; 07-06-2009 at 05:03 AM.
Dammit, you're going to make everybody awk users ....
one of the things good about learning awk, is that you can totally skip learning sed, since their capabilities overlap (and awk is a small programming language itself)
like i said , read the link. If you do, you will come across IGNORECASE. Set it to 1.
Yeah I did, but they also said
Quote:
"In general, you cannot use IGNORECASE to make certain rules case-insensitive and other rules case-sensitive, because there is no straightforward way to set IGNORECASE just for the pattern of a particular rule."
And since I may use awk as a case sensitive find&replace latter on, I would like to avoid changing things like that.
So, would you or someone else have any pointers as to how I would get it to work the other way (as stated in my previous post.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.