192 Word Frequency
Write a bash script to calculate the frequency of each word in a text file words.txt.
For simplicity sake, you may assume:
words.txtcontains 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.txt has 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
192 Word Frequency的更多相关文章
- LeetCode(192. Word Frequency)
192. Word Frequency Write a bash script to calculate the frequency of each word in a text file words ...
- LeetCode 192. Word Frequency
分析 写bash,不太会啊…… 难度 中 来源 https://leetcode.com/problems/word-frequency/ 题目 Write a bash script to calc ...
- [leetcode shell]192. Word Frequency
统计words.txt中每个单词出现的次数并排序 解法1: cat words.txt | tr -s ' ' '\n' | sort | uniq -c | sort -r | awk '{prin ...
- Individual Project - Word frequency program-11061171-MaoYu
BUAA Advanced Software Engineering Project: Individual Project - Word frequency program Ryan Mao (毛 ...
- Word Frequency
https://leetcode.com/problems/word-frequency/ Write a bash script to calculate the frequency of each ...
- [Bash]LeetCode192. 统计词频 | Word Frequency
Write a bash script to calculate the frequency of each word in a text file words.txt. For simplicity ...
- [LeetCode] Word Frequency 单词频率
Write a bash script to calculate the frequency of each word in a text file words.txt. For simplicity ...
- [CareerCup] 17.9 Word Frequency in a Book 书中单词频率
17.9 Design a method to find the frequency of occurrences of any given word in a book. 这道题让我们找书中单词出现 ...
- Individual Project - Word frequency program - Multi Thread And Optimization
作业说明详见:http://www.cnblogs.com/jiel/p/3978727.html 一.开始写代码前的规划: 1.尝试用C#来写,之前没有学过C#,所以打算先花1天的时间学习C# 2. ...
随机推荐
- ZOJ 4019 Schrödinger's Knapsack
Schrödinger's Knapsack Time Limit: 1 Second Memory Limit: 65536 KB DreamGrid has a magical knap ...
- FZU - 1688 Binary land
题目链接 Problem 1688 Binary land Accept: 72 Submit: 171Time Limit: 1000 mSec Memory Limit : 3276 ...
- Java编程思想 学习笔记8
八.多态 在面向对象的程序设计语言中,多态是继数据抽象和继承之后的第三种基本特征. 多态通过分离做什么和怎么做,从另一角度将接口和实现分离开来. “封装”通过合并特征和行为来创建新的数据类型.“实现 ...
- SQL 语言类型
结构化查询语言(Structured Query Language),简称SQL,是数据库编程的核心语言. SQL的发展是从1974年开始的,其发展过程如下: 1974年 - 由Boyce和Chamb ...
- Linux - 文件操作
touch file # 创建空白文件 rm -rf 目录名 # 不提示删除非空目录(-r:递归删除 -f强制) dos2unix # windows文本转linux文本 unix2dos # lin ...
- [C++]求解三元一次方程组
/** * author:johnny zen * date:2017-09-20 11:19 * function:Calculate Ternary system of equations * n ...
- 第18月第20天 tensorflow安装
1. # Mac OS X $ sudo easy_install pip # Mac OS X, CPU only: $ sudo easy_install --upgrade six $ sudo ...
- 【SVN】svn使用方法
下载安装TortoiseSVN 下载地方 安装成功后 TortoiseSVN清除凭证 右击空白处-TortoiseSVN-Settings打开Settings窗口后做如下操作: svn在idea中的使 ...
- AutoML技术现状与未来展望
以下内容是对AutoML技术现状与未来展望讲座的总结. 1.机器学习定义 <西瓜书>中的直观定义是:利用经验来改善系统的性能.(这里的经验一般是指数据) Mitchell在<Mach ...
- 2018-2019-2 网络对抗技术 20165230 Exp5 MSF基础应用
目录 1.实验内容 2.基础问题回答 3.实验内容 任务一:一个主动攻击实践 漏洞MS08_067(成功) 任务二:一个针对浏览器的攻击 ms11_050(成功) ms14_064(成功) 任务三:一 ...