Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed issues on Solaris, search/replace not working

Status
Not open for further replies.

cheguvera

Programmer
Oct 13, 2005
32
GB
Hi,

I am on Sun Solaris and struggling with a very simple sed command.
I want to search and replace, ignoring the case.
Lets say, I have a file,

Abcd
abCd
abcD

And I issue a command,

sed -e 's/abcd/CORRECT/i' my_file

This should give output like,

CORRECT
CORRECT
CORRECT

But, my above sed command is giving error like,

sed: command garbled: s/abcd/CORRECT/i

If I take out the 'i' from the command, it runs but then its case sensitive.

What is the flag for ignoring the case on Solaris ?
What can be another way out of this issue ?

Please help.

Thanks
 
sed 's/[aA][bB][cC][dD]/CORRECT/' my_file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Thanks for the reply.

Initially I thaught of this option, but actually, I have nearly 10 possible words to replace and the words are made up of 10 to 20 charactors each.

Basically, I have no option other than what you have suggested. But, previously on AIX and other Unix flavours I have used this flag 'i' for ignorecase. So, was trying to find if there is a equivallant to this. Or if there is another version of sed, like there are grep and egrep.

Thanks again.
 
Thanks Feherke.

But with upper case I, its the same error.

 
echo ":set ic\n1,\$s!abcd!CORRECT!\n:wq" | ex -s my_file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

That was cool.
That worked and my goal is met.

Now I am left with just curiocity about sed not working.

Thanks again
 
Well, some seds have the i modifier on the s/orig/new/ command, and some seds don't. Check your man page. It's not in my AIX 5.3 sed's man page.

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top