Replace Text in the middle of string with wild character

"KRiTs" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Hi All

Need urgent help with this

I have large file which has following lines

<SHOUT DEST="ECS" MESSAGE="JOBNAME HAS ENDED NOTOK" URGENCY="R" WHEN="NOTOK"/>

Now I want append a word after MESSAGE=" with a condition that the line ends with WHEN="NOTOK"/> 

as there are other lines ending with WHEN="OK"/> which should not be touched.

Challenge is the actual text within MESSAGE "" would vary


------------------------------------------------------------------------i tried sed with start and stop pattern but it turn on the flag and replaces even the other lines as for those also the start string is same.
----------------------------------------------------------------------

I tried \1 \2 option also but to no avail.


Basically i want to have wild cad in the middle of string, have constant start and end strings and only if the start and end string matches replacement should happen in the middle.


Thanks
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.