linux系统中统计文本中单词出现的次数

1、测试数据

[root@PC3 test]# cat a.txt
e i e s
d e t q
s g e g

2、

[root@PC3 test]# cat a.txt
e i e s
d e t q
s g e g
[root@PC3 test]# sed 's/ /\n/g' a.txt
e
i
e
s
d
e
t
q
s
g
e
g
[root@PC3 test]# sed 's/ /\n/g' a.txt | sort | uniq -c
      1 d
      4 e
      2 g
      1 i
      1 q
      2 s
      1 t
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14684703.html