【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.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.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
Note: Don't worry about handling ties, it is guaranteed that each word's frequency count is unique.
Could you write it in one-line using Unix pipes?

【193】Valid Phone Numbers

【194】Transpose File

【195】Tenth Line

【leetcode】bash脚本练习的更多相关文章

  1. grep 查找bash脚本中的注释代码

    出于安全性的考虑,不建议在bash脚本中注释掉不使用的代码.也就是说如果某段代码不使用了,那么应该删除掉,而不是简单地注释掉.假如你突然意识到这一点,而以前并没有遵从这个原则,现在需要找出脚本中的注释 ...

  2. Bash 脚本编程语言中的美学与哲学

    我承认,我再一次地当了标题党.但是不可否认,这一定是一篇精华随笔.在这一篇中,我将探讨 Bash 脚本语言中的美学与哲学. 这不是一篇 Bash 脚本编程的教程,但是却能让人更加深入地了解 Bash ...

  3. bash 脚本编程 利用 “=” 赋值时,左右不能留空格

    对脚本变量用“=”赋值时, "=" 左右不能留有空格,否则会提示错误. 比如以下例子: #!/bin/bash BEGIN_TIME = `date +%H:%M:%S` ./a. ...

  4. Bash脚本15分钟进阶指导

    首先声明这是网上摘来的.这里的技术技巧最初是来自谷歌的“Testing on the Toilet” (TOTT).这里是一个修订和扩增版本. 脚本安全 我的所有bash脚本都以下面几句为开场白: # ...

  5. Bash脚本实现批量作业并行化

    http://jerkwin.github.io/2013/12/14/Bash%E8%84%9A%E6%9C%AC%E5%AE%9E%E7%8E%B0%E6%89%B9%E9%87%8F%E4%BD ...

  6. 【转】如何调试bash脚本

    本文转自:http://coolshell.cn/articles/1379.html Bash 是Linux操作系统的默认Shell脚本.Shell是用来处理操作系统和用户交互的一个程序.Shell ...

  7. 详解在bash脚本中如何获取自身路径

    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 这是stac ...

  8. 一个很不错的bash脚本编写教程

    转自 http://blog.chinaunix.net/uid-20328094-id-95121.html 一个很不错的bash脚本编写教程,至少没接触过BASH的也能看懂! 建立一个脚本 Lin ...

  9. Bash脚本15分钟进阶教程

    转载: Bash脚本15分钟进阶教程 这里的技术技巧最初是来自谷歌的"Testing on the Toilet" (TOTT).这里是一个修订和扩增版本. 脚本安全 我的所有ba ...

  10. 【转】Bash脚本实现批量作业并行化

    首先附上自己常用的代码 ---------------------------------------------------------------------------------------- ...

随机推荐

  1. 【记录】STS设置maven远程仓库,加快下载jar包

    在STS中windows->preferences->maven->user settings 修改user settings里setting.xml配置文件 <?xml ve ...

  2. git注意事项

    1,在github中新建空的工程,第一次提交代码的时候 使用命令  $ git push -u origin master -f 后面就直接push就行了

  3. iterators和generators

    iterators >>> mylist=[x*x for x in range(3)] >>> mylist [0, 1, 4] generators >& ...

  4. SSH出错

    [root@node01 ~]# ssh node02 ssh_exchange_identification: Connection closed by remote host 修改连接数无效 [r ...

  5. 调试Spark应用

    本文摘自:<Hadoop专家-管理.调优与Spark|YARN|HDFS安全>Sam R. Alapati 一.通过日志聚合访问日志 二.当日志聚合未开启时

  6. GA来源分析

    网页中广告素材分为:文字,图片和FLASH三种.针对这三种素材,2种有无参数的情况,新旧版GA收集到的结果为: 提醒:FLASH素材如果不加参数收集不到来源: 具体GA参数如下: 可参考:https: ...

  7. springcloud中provider-product依赖

    <dependencies> <dependency> <groupId>cn.lijun.springcloud</groupId> <arti ...

  8. javaweb判断当前请求是否为移动设备访问的方法

    由于移动端和pc端还是稍微有些区别的,我觉得最好是在一个地儿统一判断,而且不要改动原先的代码,这样可以从一定程度上减少bug的数量.我的想法是首先应该判断当前请求是否为移动端,然后设一个标识到sess ...

  9. 浅谈scrapy框架安装使用

    Scrapy笔记: 一 安装: pip3 install wheel pip3 install lxml pip3 install pyopenssl pip3 install -i https:// ...

  10. 启发式分治:2019牛客多校第三场 G题 Removing Stones

    问题可以转换为求有多少个区间数字的总和除2向下取整大于等于最大值.或者解释为有多少个区间数字的总和大于等于最大值的两倍(但是若区间数字总和为奇数,需要算作减1) 启发式分治: 首先按最大值位置分治,遍 ...