You can suppress output from grep using -q option, so that it only returns the exit status.
To handle this in bash - you need to combine grep -q with an immediate check of the exit code for last process to quit - $?:
grep -q 'dmitri' /etc/passwd;
case "$?" in
"0") echo "match" ;;
"1") echo "no match" ;;
*) echo "error" ;;
esac