Randomly select one line from file.txt, remove everything after the first whitespace, and search for a string that consists of 9 alphanumeric characters.
shuf -n 1 file.txt | sed -e 's/\s.*//' | xargs grep -Ei '^[A-Za-z0-9]{9}$'