Format #postgres output for scripting use
How to format a pg query output correctly so that it can be used from a shell script
query="SELECT * FROM sometable";
RESULTS=`psql -d table_name -c "$query" -q -F";" -A`;
for row in $RESULTS ;
do
# Put your action on each row here
# you can split it with awk,
# doing something like
first=`echo $row|awk'{split($0,a,";");print a[1]}'`;
# Remember that first row is field description
done;