We are all familiar with the tr command, which can delete replacements and delete strings. In English, we often need to count the frequency of words that appear in English. If we use the conventional method and set up a calculator to count them one by one, it is quite time-consuming. At this time, use the tr command to replace the space split with a newline character, and then use the tr command to delete the period, comma, and exclamation mark after some words. First look at the this.txt file to be replaced
For the above text file, if you want to count the top 10 words that appear the most times in the text, you can use the following command [root@linux ~]# cat this.txt | tr ' ' '\n' | tr -d '[.,!]' | sort | uniq -c | sort -nr | head -10 10 is 8 better 8 than 5 to 5 the 3 of 3 Although 3 never 3 be 3 one It’s very convenient! Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Detailed explanation of the implementation method of database multi-table connection query
>>: Detailed explanation of Vue3's sandbox mechanism
Preface After the project is migrated to .net cor...
Installation environment: CentOS7 64-bit MINI ver...
Table of contents 1. Understanding 2. Use 1. h() ...
Enter Alibaba vector icon library Alibaba Vector ...
1. Use the <a> tag to complete <a href=&...
What I want to share today is to use native JS to...
After entering the Docker container, if you exit ...
Today I had a sneak peek at IE8 beta 1 (hereafter...
It mainly shows how to configure X-Frame-Options,...
Preface This experiment prepares two virtual mach...
Copy code The code is as follows: <!DOCTYPE ht...
Tag type (display mode) HTML tags are generally d...
If a form field in a form is set to disabled, the ...
introduction The previous article introduced the ...
The examples in this article are all written in s...