I am looking for a command to count number of all words in a file. For instance if a file is like this,
today is a good day
then it should print
5, since there are
5 words there.
I came up with this for JUST the number:
I also like the
The better solution is using Perl:
You can check the source code of
The bigger the file is, the more efficient Perl is with respect to
Let's use AWK!
This lists the frequency of each word occurring in the provided file. I know it's not what you asked for, but it's better! If you want to see the occurrences of your word, you can just do this:
I even added this function to my .dotfiles
Source: AWK-ward Ruby