You need a better search, the grep command can search using regular expressions.
From man grep:
DESCRIPTION
grep searches the named input FILEs for lines containing a
match to the given PATTERN.
And as "Ulrich Schwarz" said, you can use the -c parameter to count.
From man grep:
-c, --count
Suppress normal output; instead print a count of matching lines for
each input file.
So, searching through the bash_history for a command execution using regular expressions and then counting them:
grep -E "EXP" .bash_history
or just
grep "EXP" .bash_history
Example: If you want to count the amount of 'rm' commands:
grep -E ^rm* /home/<user>/.bash_history -c
or just
grep ^rm* /home/<user>/.bash_history -c
Example 2: If you want to count the amount of commands that has the string X:
grep -E X /home/<user>/.bash_history -c
or just
grep X /home/<user>/.bash_history -c
For more info about regular expressions: GNU - grep-regular-expression-syntax
-o
ingrep
?-c
option might come in useful.