access columns returned by psql from bash
In addition to what @Milen already provided, you may want -A (--no-align) to remove leading white space:

psql "con params" -tAc "SELECT pg_size_pretty(pg_database_size('mydb'))"


As an aside: pg_size_pretty() may or may not be of interest.