Log in
updated 11:29 AM UTC, May 4, 2016

how to count number of occurrences of a word in Ubuntu

We come across several situations where we need to know the number of occurrences of a word in a file.

for example: when you want to know no of rows in a JSON file.

Here is a command which does exactly what we need, it combines grep with wc.

grep -o "YourString" YourFileToSeachTheString.Ext | wc -w


Powered by Bullraider.com
Follow Us on Twitter
Find Us on Facebook
Follow Us on Google
Follow Us on Pinterest