psql non restituisce direttamente uno status speciale per “nessuna riga trovata”, ma puoi combinarlo con un altro comando.
psql -U postgres -d db -t -c "select * from user where id=1 and name='Joe'" | egrep .Se non viene restituito nulla, egrep esce con stato diverso da zero. L’opzione -t sopprime header e riepilogo.