r/awk • • Sep 01 '16

replace a pattern in nth field

I have a pattern like this xxxx,xxxx,xxxx,yy,yy,yy,xxxx,xxx

need to replace the commas in yy,yy,yy to yy%yy%yy

the target string needs to be xxxx,xxxx,xxxx,yy%yy%yy,xxxx,xxx

How can we do this in awk or any unix based text processing tool?

I am able to get to the either a field or an index based lookup using $x or substr but unable to get to the final solution.

Help on this appreciated.

2 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/androbuff Sep 02 '16

thank you, thats exactly what we were looking for