bash - from Linux command line, find number of lines in which a string occurs -


i have file in location /home/someuser/sometext.txt . want count number of lines in particular string occurs. what's way linux command line?

grep -c switch need:

grep -c "pattern" /home/someuser/sometext.txt 

alternate solution using awk:

awk '/regex/{c++}end{print c+0}' /home/someuser/sometext.txt 

Comments