#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep 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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep 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
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep 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...
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep 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??

IMN logo majestic logo threadwatch logo seochat tools logo