title: Convert query result into array in shell script
body: <p>I am trying very simple thing using shell script on <code>BASH</code> shell. I am trying to get keyids of all Users into an array in a shell script. I will later loop them for further processing. </p>
  
  <p>I wrote very simple code. But I am stuck while converting a space separated QUERY_RESULTS string into an array. </p>
  
  <p>I tried various options e.g. <code>set -A</code> , <code>read -a</code>, <code>array=( $ QUERY_RESULTS } )</code> etc. 
  Nothing is working for me. Every-thing I try, gives me some error.</p>
  
  <p>For e.g. </p>
  
  <ul>
  <li><code>set -A</code> gives me <code>illegal option -A</code>.    </li>
  <li><code>read -a</code> also gives me <code>illegal option -a</code>.    </li>
  <li><code>array=( $ QUERY_RESULTS } );</code> gives me <code>( unexpected</code>.</li>
  </ul>
  
  <p>Below is my code. Please help me here. </p>
  
  <pre><code>#IFS="";
  echo "Get list of Active Users from Table ";
  QUERY_RESULTS=$( mysql -u username password -e "SELECT keyid from users where isActive = 1" );
  echo $QUERY_RESULTS;
  #eval `read -a arr &lt;&lt;$QUERY_RESULTS`;
  #array=( $ QUERY_RESULTS } );
  echo $array;
  </code></pre>