Article 598VV [BASH][SED] Find pattern and replace it's [pattern's] last character

[BASH][SED] Find pattern and replace it's [pattern's] last character

by
czezz
from LinuxQuestions.org on (#598VV)
Hi all,
Can anyone please give me a little help with sed here?

I have following example file:
Code:cat test
blablalb A i B. E. lalalalal.
A. tralala,la A Bi C.
B. elellfdew A. fww.
C. DiDweofjoie zalamki T.Following grep will highlight the pattern that Im trying to change:
Code:cat test | grep " i [A-Z][.]" (mind the SPACE before "i")So, eventually what Im trying to get is:
Code:blablalb A i B, E. lalalalal.
A. tralala,la A B i C,
B. elellfdew A. fww.
C. DiDweofjoie zalamki T.Normaly, if there was no pattern I would go for someting like this:
Code:sed -e 's/ i [A-Z][.]/ i [A-Z][,]/g' test
sed -e '/ i [A-Z][.]/s//,/' testAny ideas how to get it?latest?d=yIl2AUoC8zA latest?i=eVzYxGIjzBA:xTOmnujGlzA:F7zBnMy latest?i=eVzYxGIjzBA:xTOmnujGlzA:V_sGLiP latest?d=qj6IDK7rITs latest?i=eVzYxGIjzBA:xTOmnujGlzA:gIN9vFweVzYxGIjzBA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments