title: Execute bash command inside awk and print command output
body: <p>Given a file <code>test.txt</code> with the following contents:</p>
  
  <pre><code>ABC DEF GATTAG GHK
  ABC DEF GGCGTC GHK 
  ABC DEF AATTCC GHK
  </code></pre>
  
  <p>the 3rd column needs to be modified, so that the string is reverse complement. Part of it can be done with a bash command:</p>
  
  <p><code>cat test.txt | cut -f3 | rev | tr ATGC TACG</code></p>
  
  <pre><code>CTAATC
  GACGCC
  GGAATT
  </code></pre>
  
  <p><strong>How can this be implemented with <code>awk</code>?</strong> <em>(there is a bigger awk script for processing of files, which this function will be added to.)</em></p>
  
  <p>One possible way this might be done is by executing <code>rev | tr ATGC TACG</code> inside of <code>awk</code>, similar to:</p>
  
  <pre><code>awk '{newVar=system("rev | tr ATGC TACG"$3); print $1 $2 newVar $4}' test.txt
  </code></pre>
  
  <p>However, this and various similar versions do not work. Can someone point out what is incorrect?</p>