Well, after fleshing out your command, I got:
psql -tc "select 1 from pg_catalog.pg_database where datname='snowdrift';" | grep -qw 1
That looks more complicated than the StackOverflow solution:
psql -lt | cut -f1 -d \| | grep -qw <db-name>
Or at least it's longer. Hmm. I guess personal taste is a big factor here.
Jake T.