shell之计算文本中单词出现频率
生活随笔
收集整理的這篇文章主要介紹了
shell之计算文本中单词出现频率
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
Word Frequency(https://leetcode.com/problems/word-frequency/description/)
Example:
Assume that?words.txt?has the following content:
the day is sunny the the the sunny is isYour script should output the following, sorted by descending frequency:
the 4 is 3 sunny 2 day 1然后來看看強大的 awk
awk -vRS='( |\n)+' '{a[$0]++}END{for(i in a)m[a[i]]=i;i=asort(a);for(;i;)print m[a[i]],a[i--]}' words.txt
?
?
?
轉載于:https://my.oschina.net/u/2277632/blog/1839399
總結
以上是生活随笔為你收集整理的shell之计算文本中单词出现频率的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 收藏夹库计算机网络的关系,云南省计算机一
- 下一篇: xmind可以画流程图吗_如何用xmin