sudo -u postgres psql SELECT datname FROM pg_database WHERE NOT datistemplate AND datname <> 'postgres';
sudo -u postgres dropdb -f
sudo -u postgres dropdb -f || sudo -u postgres psql SELECT datname FROM pg_database WHERE NOT datistemplate AND datname <> 'postgres';
#!/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