這篇文章主要介紹linux中如何使用tr命令統(tǒng)計英文單詞出現(xiàn)頻率,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供東平網(wǎng)站建設(shè)、東平做網(wǎng)站、東平網(wǎng)站設(shè)計、東平網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、東平企業(yè)網(wǎng)站模板建站服務(wù),10多年東平做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
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
以上是“l(fā)inux中如何使用tr命令統(tǒng)計英文單詞出現(xiàn)頻率”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站欄目:linux中如何使用tr命令統(tǒng)計英文單詞出現(xiàn)頻率
分享URL:http://m.newbst.com/article14/jeigge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護、全網(wǎng)營銷推廣、服務(wù)器托管、品牌網(wǎng)站建設(shè)、、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)