All,
I have thousands of lines in a file with following format
DATA=_ONE_XXX_YYY_CCC_HHHG_
DATA1=_GGG_JJJJ_HHH_UUU_JJJJ_HHHH_LLL_
DATA3=_MMM_GG_NN_QQQQ_FFF_III_
I want to replace _ with . by ignoring the first (=) and last ()
So that out put should looks like
DATA=_ONE.XXX.YYY.CCC.HHHG_
DATA1=_GGG.JJJJ.HHH.UUU.JJJJ.HHHH.LLL_
DATA3=_MMM.GG.NN.QQQQ.FFF.III_
Can someone help on this?
Thanks
Bala
Please use code tags
Try this if the input file pattern is what you have mentioned
sed 's/\([A-Z]\)_\([A-Z]\)/\1.\2/g' infile
--ahamed
1 Like
RudiC
3
Try
$ sed -r 's:([^=])_([^$]):\1.\2:g' file
DATA=_ONE.XXX.YYY.CCC.HHHG_
DATA1=_GGG.JJJJ.HHH.UUU.JJJJ.HHHH.LLL_
DATA3=_MMM.GG.NN.QQQQ.FFF.III_
If your sed does not allow for extended regexes, replace the ( and ) by \( and \).
This one is working for me...