#!/bin/bash
for DBNAME in $( psql -q -c "\t" -c "\a" -c "SELECT datname FROM pg_database WHERE NOT (datistemplate AND datname <> 'postgres');" )
do
dropdb -f $DBNAME
done
psql -q -c "\t" -c "\a" -c "SELECT datname FROM pg_database WHERE NOT (datistemplate AND datname <> 'postgres');" | xargs -l1 dropdb -f