what is the Unix and Linux command to list the number of occurrences of a word in a file?
I did not get the results I was looking for using grep -c 'word' <file name>
I would like to display:
word
word
word
and the number 3
what is the Unix and Linux command to list the number of occurrences of a word in a file?
I did not get the results I was looking for using grep -c 'word' <file name>
I would like to display:
word
word
word
and the number 3
Assuming word
shows up at most once per line (or you don't care), you can do it with a simple pipe:
grep word file | wc -l