I have the following pattern:
$ echo -e "1>1>659,659>659>660\n1>1>683,683>683>684\n1>1>712,712>712>713\n1>1>1080648,1>1>1080660\n1>1>1081100,1>1>1081114"
1>1>659,659>659>660
1>1>683,683>683>684
1>1>712,712>712>713
1>1>1080648,1>1>1080660
1>1>1081100,1>1>1081114
I want to replace patterns where the same numbers appear sequentially between commas and the larger than (>) sign. So, to identify with grep I would do:
$ echo -e "1>1>659,659>659>660\n1>1>683,683>683>684\n1>1>712,712>712>713\n1>1>1080648,1>1>1080660\n1>1>1081100,1>1>1081114" |
grep -Eo "([0-9]+),\1>\1"
659,659>659
683,683>683
712,712>712
That is two back-references to the same group.
I know that using gensub() in awk I can have back-references in the replacement field. But how could I have that in the regexp field? Something like this:
result = gensub(/([0-9]+),\\1>\\1/,"my replaced string", "g", string)
How can I achieve that?