shell 统计单词频率

本文介绍如何利用Shell脚本对文本进行处理,统计其中每个单词出现的次数,实现简单的文本分析功能。通过读取文件内容,利用awk、sort和uniq命令,可以有效地计算并展示文本中单词的频率。
摘要由CSDN通过智能技术生成
#!/bin/bash
#n个出现频率最高的单词
help(){ echo "该shell脚本统计一个文本中出现次数最多的n个单词"
	      echo "usage: sh "$0" filename n"
	      echo "filename 为你要统计的文本名称 n为要统计的单词个数"
	      echo "sh "$0" englist_statment.txt 10"
	    }
	    
:<<EOF

First Flight
  Mr. Johnson had never been up in an aerophane before and he had read a lot about air accidents, so one day when a friend offered to take him for a ride in his own small phane, Mr. Johns
on was very worried about accepting. Finally, however, his friend persuaded him that it was very safe, and Mr. Johnson boarded the plane.
  His friend started the engine and began to taxi onto the runway of the airport. Mr. Johnson had heard that the most dangerous part of a flight were the take-off and the landing, so he w
as extremely frightened and closed his eyes.
  After a minute or two he opened them again, looked out of the window of the plane, and said to his friend, Look at those people do
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值