使用unix查找文件中最常用的条目

Mah*_*qui 1 unix file gnuplot

我有一个包含大约2,000,000个条目的文件 - 只有一列包含许多条目,所有数字.我想快速找出文件中最常见的数字是什么..有没有办法用unix做到这一点?我知道如何使用gnuplot这样做,但这是一个有点乏味的方式,并想知道是否只是通过使用一些unix命令更简单的方法?就像我的档案一样

1
1
1
2
3
4
Run Code Online (Sandbox Code Playgroud)

然后我希望它读取文件并给我答案1,因为这是最常见的.

pio*_*kuc 6

你可以这样做:

$ cat file|sort -n|uniq -c|sort -n|tail -n 1|awk '{print $2}'
Run Code Online (Sandbox Code Playgroud)