It should be:
grep -E '^[[:alpha:]]{4}$' words
We bind it (since the 5-letter string also contains the 4-letter string), and the POSIX character classes must be contained in the bracket expression ( [] ). In addition, we provide for the shell. And it needs to be expanded, so -E.
source share