SELECT 1 FROM pg_roles WHERE rolname='USR_NAME'
E in termini di riga di comando (grazie a Erwin):
psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='USR_NAME'"
Produce 1 se trovato e nient'altro.
Cioè:
psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='USR_NAME'" | grep -q 1 || createuser ...