且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在文件中查找重复的行并计算每行重复的次数?

更新时间:2023-12-01 11:58:04

假设每行有一个数字:

sort <file> | uniq -c

您也可以在 GNU 版本中使用更详细的 --count 标志,例如在 Linux 上:

You can use the more verbose --count flag too with the GNU version, e.g., on Linux:

sort <file> | uniq --count