Find all files with the extension ".sh" in the entire file system, print the file name, sort the results randomly, take the first result, and search for the string "foo" in that file.
find / -name '*.sh' -type f -printf '%f\n' | sort -R | head -n1 | xargs grep -i 'foo'