title: Get Teradata BTEQ query result in a unix variable
body: <p>I am writing a shell script, where I need a result of BTEQ query in Teradata into a unix variable. </p>
  
  <p>I tried,</p>
  
  <pre><code>    testabcd=$(bteq &lt;&lt; EOF 2&gt;&amp;1 &gt;&gt; $LOG_FILE
       .LOGON ${HOST}/${USER},${PASSWORD}
       DATABASE ${SRC_DB};
       .set width 2000;
        .set titledashes off;
       SELECT COUNT(*) FROM ${SRC_DB}.${SOURCE_TABLE};
      .LOGOFF;
      .QUIT;
      .EXIT
       EOF)
  
        echo "The count is: " $testabcd
  </code></pre>
  
  <p>The query runs successfully but the variable is not assigned with the output. Any suggestions?</p>