192 Word Frequency
2018-07-13 17:24
363 查看
Write a bash script to calculate the frequency of each word in a text file
words.txt.
For simplicity sake, you may assume:
words.txt
contains only lowercase characters and space' '
characters.- Each word must consist of lowercase characters only.
- Words are separated by one or more whitespace characters.
Example:
Assume that
words.txthas the following content:
the day is sunny the the the sunny is is
Your script should output the following, sorted by descending frequency:
the 4 is 3 sunny 2 day 1
统计单词出现的次数,并倒序输出
awk '{for(i=1;i<=NF;i++)res[$i]++}END{for(var in res)print var , res[var] | "sort -k 2 -nr"}' words.txt
相关文章推荐
- leetcode-shell-192. Word Frequency
- leetcode-192 Word Frequency
- leetcode 192. Word Frequency
- [Leetcode] 192. Word Frequency
- LeetCode 192 Word Frequency
- leetcode192. Word Frequency
- 192 - Word Frequency
- 192. Word Frequency
- ASP.NET 缓存(五)--使用文件依赖项缓存页输出http://www.opent.cn/?action=show&id=192
- 192.168.1.100 转为192、168、1、100四个整数 sscanf
- CF 192 DIV2
- Codeforces Round #192 (Div. 2) <全>
- Codeforces Round #192 (Div. 2)
- sgu192:RGB(计算几何)
- Word Frequency
- Codeforces Round #192 (Div. 1) B. Biridian Forest(BFS)
- 192_IO流_BufferedReader_接收用户键盘输入
- 把一个c类的网络地址192-168-1-0划分为6个子网,请计算出...
- UOJ #192. 【UR #14】最强跳蚤
- 引用VCleaner 大哥2 分类: 工作生活经历 2008-07-18 10:52 192人阅读 评论(0) 收藏