亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

tr命令在統(tǒng)計英文單詞出現(xiàn)頻率中的妙用

 更新時間:2019年03月02日 15:01:44   作者:杰瑞26  
今天小編就為大家分享一篇關(guān)于tr命令在統(tǒng)計英文單詞出現(xiàn)頻率中的妙用,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

tr命令我們很清楚,可以刪除替換,刪除字符串。 在英文中我們要經(jīng)常會經(jīng)常統(tǒng)計英文中出現(xiàn)的頻率,如果用常規(guī)的方法,用設(shè)定計算器一個個算比較費事,這個時候使用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!

上面的文本文件,如果要文中出現(xiàn)次數(shù)的最多的10個單詞統(tǒng)計出來,可以使用下面的命令

[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

可謂非常方便!

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

最新評論