title: Assign AWK result to variable
body: <p>This should be pretty straightfoward and I don't know why I am struggling with it.</p>
  
  <p>I am running the following psql command from within a shell script in order to find out whether all indexes have been dropped before inserting data.</p>
  
  <pre><code>INDEXCOUNT=$(psql -p $dbPort -U enterprisedb -d main_db -c "select Count(*) from all_indexes where index_schema = 'enterprisedb';")
  </code></pre>
  
  <p>At this point, INDEXCOUNT is equal to “COUNT ------- 0”</p>
  
  <p>Now if I echo the following line I get the result I want -</p>
  
  <pre><code>echo $INDEXCOUNT | awk '{print $3}'
  </code></pre>
  
  <p>How do I assign the value of <code>$INDEXCOUNT | awk ‘{print $3}’</code> to a variable to check it in an “IF” statement?</p>
  
  <p>For example:</p>
  
  <pre><code>RETURNCOUNT=$INDEXCOUNT | awk '{print $3}'
  </code></pre>