0
給出一個.txt文件用空格分隔的詞語,如:Awk:CJK字符有什麼問題? #Korean
But where is Esope the holly Bastard
But where is 생 지 옥 이 군
지 옥 이
지 옥
지
我 是 你 的 爸 爸 !
爸 爸 ! ! !
你 不 會 的 !
而且awk的功能:
cat /pathway/to/your/file.txt | tr ' ' '\n' | sort | uniq -c | awk '{print $2" "$1}'
我得到以下輸出在我的控制檯對於韓文單詞無效(英文和中文空格分隔的單詞有效)
생 16
Bastard 1
But 2
Esope 1
holly 1
is 2
the 1
where 2
不 1
你 2
我 1
是 1
會 1
爸 4
的 2
如何讓它適用於韓語單詞? 注:我實際上有300.000行和接近2百萬字。
編輯:二手答案:
$ awk '{a[$1]++}END{for(k in a)print a[k],k}' RS=" |\n" myfile.txt | sort > myfileout.txt
很簡單:太棒了!謝謝。 – Hugolpz 2013-03-24 16:29:17
這個答案是[在detals裏解釋](http://stackoverflow.com/questions/15598935/awk-how-to-output-result-into-myfile-txt-words-frequency/15600106?#15600106) – Hugolpz 2013-03-24 16:37:57