习题(3) – 统计一个文件中每个单词重复出现的次数

统计一个文件中每个单词重复出现的次数

[root@redhat root]# cat 1.txt
0123456789 12345

abcdefghij 12345
12345
67890 67890 zb
ssj
zb
root
test
0123456789
abcdefghij
12345
67890
ssj
zb
root
test
zb

结果

[root@redhat root]# tr -s "t| " "n" <1.txt|sort|uniq -c
2 0123456789
4 12345
3 67890
2 abcdefghij
2 root
2 ssj
2 test
4 zb

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注