Count the number of times a word appears in a file

后端 未结 3 451
一个人的身影
一个人的身影 2020-12-14 13:54

What is an easy way to count the number of times a word appears in a file?

3条回答
  •  借酒劲吻你
    2020-12-14 14:21

    This will also count multiple occurrences of the word in a single line:

    grep -o 'word' filename | wc -l
    

提交回复
热议问题