You can do it by combining tr and wc commands. For example, to count e in the string referee
echo "referee" | tr -cd 'e' | wc -c
output
4
Explanations: Command tr -cd 'e' removes all characters other than 'e', and Command wc -c counts the remaining characters.
参考:
https://stackoverflow.com/questions/16679369/count-occurrences-of-a-char-in-a-string-using-bash