sed to update string pattern

Hi
I have to update string pattern using sed. If I find any keyword "post" I have to add a function "yahoo" to that keyword. The keyword "post" may or may not come with some prefix too like "abc.post" or "def.post" etc or only "post". The sed must only change when word is completely matched. Like compost must remain compost only. Only post should change to yahoo(post) or abc.post to yahoo(abc.post).
Below is sample example:
Input:

Hi this is another abc.post. This post is new. Not compost. Dummy String - dbc.post.

Output Required:

Hi this is another yahoo(abc.post). This yahoo(post) is new. Not compost. Dummy String - yahoo(dbc.post).

I m trying
sed -i "s/\bpost\b/yahoo(post)/g"

but this does not takes care of abc.post, dbc.post & other similar prefix.

Thanks in advance.

Hello dashing201,

Could you please try following.

awk '{for(i=1;i<=NF;i++){if($i ~ /\.[Pp][oO][sS][tT]/ || $i ~ /^[Pp][oO][sS][tT]$/){sub(/\.$/,"",$i);$i="yahoo("$i")."}}} 1'  Input_file

Thanks,
R. Singh

Hi Ravindra

Thanks for quick reply.
Actual "post" is also a dummy keyword.
I have to run while loop for 20,000 such keywords.

Please share more generic solution.

Sorry Mate, we are here are NOT for free coding service. You have to show your efforts(it could be logical or could be coding) which you have put in order to solve your problem. Then You should mention all details in single shot itself rather than asking us questions each time adding some stuff in there.

Thanks,
R. Singh

thanks anyways.
I have already shared above what I tried.
May be I didn't put things very clearly at first place. But if things are "hardcoded" life becomes so simple. Right ?

Hello dashing201,

How come anyone will come to know that you have 20'000 keywords which you have do like this? Can you take my code as a start and post it here what you have tried then?

Thanks,
R. Singh

Hi Ravindra

I have tried your suggestion with some modification

echo "Hi this is another abc.post. This post is new. Not compost. Dummy String - dbc.post."|awk '{for(i=1;i<=NF;i++){if($i ~ /\.post/ || $i ~ /^post$/){sub(/\.$/,"",$i);$i="yahoo("$i")."}}} 1'

Only thing is output is having "." after post keyword.

Hi this is another yahoo(abc.post). This yahoo(post). is new. Not compost. Dummy String - yahoo(dbc.post).

I don't need that extra "." in output - This yahoo(post). is new.

Thanks

Try

sed 's/\b([[:alnum:]]*\.)*post\b/yahoo(&)/g' file
Hi this is another yahoo(abc.post). This yahoo(post) is new. Not compost. Dummy String - yahoo(dbc.post).