title: Bash variable from command with pipes, quotes, etc
body: <p>I have a command I'm using to get the hostname.localdomain:</p>
  
  <pre><code>dig axfr @dc1.localdomain.com localdomain.com | grep -i Lawler | awk '{ getline ; $1=substr($1,1,length($1)-1); print $1 ; exit }'
  </code></pre>
  
  <p>This nicely returns a result like:</p>
  
  <blockquote>
    <p>michael.lawler.localdomain.com</p>
  </blockquote>
  
  <p>I'd like to further use that result as a variable in a Bash script.</p>
  
  <p>It seems I'm having trouble getting past the first pipe.</p>
  
  <p>If I <code>VAR="dig axfr @dc1.localdomain.com localdomain.com | grep -i Lawler | awk '{ getline ; $1=substr($1,1,length($1)-1); print $1 ; exit }'"</code></p>
  
  <p>...I get back the entire zone transfer. I've also tried many minor changes, adding <code>$</code> before the <code>dig</code> command, without quotes, but nothing seems to work. How can I fix this?</p>