title: Bash script & PostgreSQL: How to access column values returned from SELECT statement
body: <p>I have a database in PostgreSQL called customers, customers has a table called CustomerInfo. CustomerInfo contains 3 columns ID, Name and address. I would like to write a bash script to get the information from the CustomerInfo table but i am not sure how to access the individual rows once i have the results of the query. Here is the script i have written:</p>
  
  <pre><code>#!/bin/bash  
  
  results=`psql -d customers -c "select * from CustomerInfo where name = 'Dave'"`
  
  echo $results['name']
  </code></pre>
  
  <p>The query runs correctly and returns the correct results but the echo command will just print everything in results. I know this is not the correct way of doing this, does anyone know of a way to get the query results as an array, or would i just have to write my own function for parsing the results?</p>
  
  <p>Thanks!</p>