Because an MD5 hash is typ­i­cally expressed as a hexa­dec­i­mal num­ber, 32 dig­its long *, all you need to do is cut 6 char­ac­ters to get a color value.

COLOR=`echo $SVG | 
       md5sum | 
       cut -c 1-6`

To con­vert any string to a color value, just reduce it to the appro­pri­ate char­ac­ters (= a-f and 0–9), pad it with an actual hex value (= ff0000 in this case) to ensure you get a min­i­mum of 6 char­ac­ters and cut 6 char­ac­ters.

STRING=`shuf -n 1 /usr/share/dict/words`
 COLOR=`echo \`echo $STRING | \
        sed 's/[^a-fA-F0-9]*//g'\`ff0000 |\
        cut -c 1-6`
echo $COLOR;