How to create md5 Hash variable?

I have a script that runs the grub-md5-crypt command based on whether the pass_value variable is a non-zero string. The md5 hash is being created in the /opt/hostconfigs/$HOST file, but I can't echo $md5_value. It is blank. Is there a way to create and echo a md5 hash variable?

if [ $pass_value != "" ]
then
grub-md5-crypt <<EOF>>/opt/hostconfigs/$HOST
$pass_value
$pass_value
EOF
md5_value=`grep '^\$' /opt/hostconfigs/$HOST` # This is where the script fails.
echo $md5_value
run1
else
run2
fi

I figured it out. I used fgrep.

md5_value=`fgrep '$' /opt/hostconfigs/$HOST`

Now when I echo $md5_value, it prints the hash value.