Count the number of lines contain a specific string using grep
Answer:
Usually when you want to count the number of lines contain a specific string, it is easy with the grep command,
e.g.
# cat input.txt | grep foo | wc -l
But actually a more direct approach would be:
# cat input.txt | grep -c foo