'How to print words and the word count

I am supposed to print both the 6-letter words and how many words there are. the file has it so that the words are on their own line. I'm just learning egrep, so this is what I arrived at. egrep '^.{6}$' nlr.txt| wc -w. It only prints the number of words that have 6 letters in them.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source