search

Loading
Showing posts with label count of a character or word in a file. Show all posts
Showing posts with label count of a character or word in a file. Show all posts

Friday, March 9, 2012

How to find the number of occurance of a character or word in a file

Some times we need to find how many times a character or a word has repeated in file. For this we can use vim. Vim is extremely powerful tool and learning some cool tricks in vim will always help you beat the heat.

So for example, i want to find how many times the word linux comes a file which is full words and lines. Imagine if the file has more than 1000 lines finding manually it will be just waste of time if you know the simple command in the vim.


We can use grep -c linux test.txt, but it will only show the number of lines where the word linux comes.
That's why we are using the vim and the below command.