Counting lines starting with a certain word

count, linux

Solution

Try this:-

  awk '/^yourwordtofind/{a++}END{print a}' file

Problem

How to count the number of lines in a text file starting with a certain word? I do not want to use `sed` and then `wc -l`. Any better solution?

Original source