题目解答:
awk '{for(i=1;i<=NF;i++){res[$i]+=1}}END{for(k in res){print k " "res[k]}}' words.txt | sort -nr -k2
cat words.txt | xargs -n1 | sort | uniq -c | sort -nr -k2 | awk '{print $2,$1}'
题目解答:
awk '{for(i=1;i<=NF;i++){res[$i]+=1}}END{for(k in res){print k " "res[k]}}' words.txt | sort -nr -k2
cat words.txt | xargs -n1 | sort | uniq -c | sort -nr -k2 | awk '{print $2,$1}'
本文标题:shell统计词频
本文链接:https://www.haomeiwen.com/subject/rhzvghtx.html
网友评论