title: Assign output of sql query to a variable in unix
body: <p>I am using the following simple UNIX script to assign the output to a variable.</p>
  
  <pre><code>count=`sqlplus -s ${DB_USER}/${DB_PASS}@${DB_INST} &lt;&lt; END
          SELECT COUNT(column_name) from table_name;
  END`
  
  echo $count
  </code></pre>
  
  <p>But I am getting the following error on executing:</p>
  
  <pre><code>SP2-0042: unknown command "END" - rest of line ignored.
  </code></pre>
  
  <hr>
  
  <p>count=`sqlplus -s ${DB_USER}/${DB_PASS}@${DB_INST} &lt;&lt; END</p>
  
  <p>When I tried to execute the above statement in putty, it was saying as "bad substitution"</p>
  
  <p>So I am using UNIX script to assign the output to a variable.</p>
  
  <p>count=<code>sqlplus DB_USER/DB_PASS &lt;&lt; END
  SELECT VERSION_NUMBER from GA_PERIODIC_REFRESH where MODULE_NAME in 'RoaminfoService';
  exit;
  END</code>
  echo $count</p>