You are specifying the character class incorrectly. The manual would tell you:
- A bracket expression is a list of characters enclosed by
[
and]
- Certain named classes of characters are predefined within bracket expressions:
[:digit:]
Digits: 0 1 2 3 4 5 6 7 8 9.
This would imply that in order to match a [:digit:]
you need to say [[:digit:]]
.
You'll find:
$ cat input | grep -o '[[:digit:]]'
2