GNU awk: accessing captured groups in replacement text
With GNU awk: echo abbc | awk ‘{ print gensub(/a(b*)c/, “Here are bees: \\1”, “g”, $1);}’ See manual here to see the difference between gsub and gensub gensub() provides an additional feature that is not available in sub() or gsub(): the ability to specify components of a regexp in the replacement text. This is done … Read more