run sql/queries (postgres) within bash

e.g.

for things-to-buy in $(psql -d database-name -U username -c “select item from glossaries where priority = ‘urgent’ “;

do

blah, blah, blah …

done

Related posts:

  1. PostgreSQL Database psql Command Line Query Sometime psql command line query can be useful when it...
  2. Exim – anti-spam per domain setting acl_check_rcpt: blah … blah … blah … deny message =...
  3. bash – dealing with backtics ” ` ” in mysql statement problem : using backticks in bash for mysql statements. e.g....
  4. Bash: How to Echo Tab and Newline While printing out result in bash, sometime we need to...

One Response to “run sql/queries (postgres) within bash”

  1. spoonfork Says:

    you can also do the following:

    echo “select * from cibailanjio” | mysql -uroot -p

Leave a Reply