UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 20th, 2003, 05:40 PM
shameem shameem is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 10 shameem User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 50 sec
Reputation Power: 0
Angry ignoring case in sed command

can anybody tell me a command to get sed command which ignores case.

example is like this
I want to search a file for the pattern "shameem" and this should replace the occurence of "SHAMEEM" also with "shammu".

cat file1 | sed "s/shameem/shammu/" > file1

so if the file1 consists of
"shameem gouse lazam SHAMEEM"

then this command should give the output as

"shammu gouse lazam shammu"

please help me in this reg...
Thank you
Shameem S

Reply With Quote
  #2  
Old November 20th, 2003, 11:50 PM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
$ echo "SoMe TeXt"| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz'/
some text

But this is a more elegant solution (nt using sed):

$ echo "SoMe TeXt" | tr '[A-Z]' '[a-z]'
some text

Reply With Quote
  #3  
Old November 21st, 2003, 12:20 PM
shameem shameem is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 10 shameem User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 50 sec
Reputation Power: 0
Angry

I am sorry this wont work. because it changes whole text. I dont want to change the remaining text other than matching pattern.
for e.g.

shameem GOUSE Lazam

I want to change this as

shammu GOUSE Lazam

but not

shammu gouse lazam

I want to replace shameem with shammu. Nothing else.
Thank you for your reply. Its a good solution for conversion from uppercase to lower case or vice versa.

if you have any idea about my issue let me know...

Reply With Quote
  #4  
Old November 21st, 2003, 01:51 PM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
I misunderstood.

Ok, new try:

$ SAMPLE="ShAmeEm GOUSE Lazam"
$ echo $SAMPLE
ShAmeEm GOUSE Lazam

$ echo $SAMPLE | sed 's/shameem/Shammu/i'
Shammu GOUSE Lazam

$ SAMPLE="SHAMEEM GOUSE Lazam"
$ echo $SAMPLE
SHAMEEM GOUSE Lazam

$ echo $SAMPLE | sed 's/shameem/Shammu/i'
Shammu GOUSE Lazam

Whatever the upper/lowercase combo of the searchstring (shameem) it will be replaced by Shammu.

BTW: What does 'Shameem/Shammu GOUSE Lazam'' mean??

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > ignoring case in sed command


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway