SELECT 1 FROM pg_roles WHERE rolname='USR_NAME'
En qua commandoregel (met dank aan Erwin):
psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='USR_NAME'"
Levert 1 op indien gevonden en niets anders.
Dat is:
psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='USR_NAME'" | grep -q 1 || createuser ...