百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>服务器> tr下令在统计英文单词涌现频率中的妙用
分享文章到:

tr下令在统计英文单词涌现频率中的妙用

发布时间:05/13 来源:未知 浏览: 关键词:

tr下令我们很分明,可以删除替代,删除字符串。 在英文中我们要经常会经常统计英文中涌现的频率,要是用通例的要领,用设定盘算器一个个算比较麻烦,这个时候运用tr下令,将空格分割替代为换行符,再用tr下令删除掉有的单词背面的点号,逗号,叹息号。先看看要替代的this.txt文件

The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

上面的文本文件,要是要文中涌现次数的最多的10个单词统计出来,可以运用下面的下令

[root@linux ~]# cat this.txt | tr ' ' '\n' | tr -d '[.,!]' | sort | uniq -c | sort -nr | head -10
10 is
8 better
8 than
5 to
5 the
3 of
3 Although
3 never
3 be
3 one

可谓非常利便!

总结

以上就是这篇文章的全部内容了,但愿本文的内容对大家的学习或者工作拥有一定的参考学习价值,感谢大家对脚本之家的支撑。要是你想理解更多相干内容请查看下面相干链接

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有157人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板