HI all,
i have a line in a file it contains
Code:
one;two_1_10;two_2_10;two_3_10;three~
now i need to get the output as
Code:
one;two_1_abc_10;two_2_abc_10;two_3_abc_10;three~ ( 1 should be replaced with 1_abc for two_[1-10]_abc_10 , and one more thing the number of occurances of two_value_10 will be dynamic.so we need to put in a loop)
Code:
can you plz plz help me
..
HI, Try this,
echo 'one;two_1_10;two_2_10;two_3_10;three~' | sed 's/\_10\;/\_abc_10\;/g'
Thanks Pravin and Scritinizer, but the thing is that
I need to search for the pattern two_[1-10]_10 and then i have to replace with two_[1-10]_abc_10 and not just replacing _10 with _abc_10 bro in
one;two_1_10;two_2_10;two_3_10;three~
can anyone help me with this....
Thanks in advance...
Try this:
sed 's/two_\(10\|[1-9]\)_10/two_\1_abc_10/g'
Try this
sed "s/\(two_[0-9][0-9]*_\)/\1abc_/g" myfile
1 Like
Thanks a lot Scrutinizer and ygemci the code is working,,,but unfortunately i m not getting desired output with Scrutinizer's code...and thanks a lot for replying bak..kudos to u all and this site,,,,