title: Escaping backslash in AWK in command substituion
body: <p>I am trying to escape backslash in AWK. This is a sample of what I am trying to do.</p>
  
  <p>Say, I have a variable</p>
  
  <pre><code>$echo $a
  hi
  </code></pre>
  
  <p>The following works</p>
  
  <pre><code>$echo $a | awk '{printf("\\\"%s\"",$1)'}
  \"hi"
  </code></pre>
  
  <p>But, when I am trying to save the output of the same command to a variable using command substitution, I get the following error:</p>
  
  <pre><code>$ q=`echo $a | awk '{printf("\\\"%s\"",$1)'}`
  awk: {printf("\\"%s\"",$1)}
  awk:               ^ backslash not last character on line
  </code></pre>
  
  <p>I am unable to understand why command substitution is breaking the AWK. Thanks a lot for your help.</p>