Linux command line has a lot of fun around itself and many tedious task can be performed very easily yet with perfection. Playing with words and characters, their frequency in a text file, etc is what we are going to see in this article.
The only command that comes to our mind, for tweaking Linux command line to manipulate words and characters from a text file is wc command.
A ‘wc‘ command which stands for word count is capable of Printing Newline, word & byte counts from a text file.
To work with the small scripts to analyze text file, we must have a text file. To maintain uniformity, we are creating a text file with the output of man command, as described below.
The above command creates a text file ‘man.txt‘ with the content of ‘manual page‘ for ‘man‘ command.
We want to check the most common words, in the above created ‘Text File‘ by running the below script.
Sample Output
The above one liner simple script shows, ten most frequently appearing words and their frequency of appearance, in the text file.
How about breaking down a word into individual using following command.
Sample Output
Note: Here, ‘-w1’ is for width.
No comments:
Post a Comment