title: GNU awk: accessing captured groups in replacement text
body: <p>This seems like it should be dirt simple, but the awk gensub/gsub/sub behavior has always been unclear to me, and now I just can't get it to do what the documentation says it should do (and what experience with a zillion other similar tools suggests should work).  Specifically, I want to access "captured groups" from a regex in the replacement string.  Here's what I think the awk syntax should be:</p>
  
  <pre><code>awk '{ gsub(/a(b*)c/, "Here are bees: \1"); print; }'
  </code></pre>
  
  <p>That should turn "abbbc" into "Here are bees: bbb".  It does not, at least not for me in Ubunutu 9.04.  Instead, the "\1" is rendered as a ^A; that is, the character with code 1.  Not what I want, of course. How do I do this?</p>
  
  <p>Thanks.</p>