uniq 命令用于检查及删除文本文件中重复出现的行列,一般与 sort 命令结合使用

    1. # sort
    2. # uniq -c : 检查文件并删除文件中重复出现的行,并在行首显示该行重复出现的次数
    3. cat test.log| grep "test" | sort|uniq -c
    4. # 输出结果:
    5. 1 test 1
    6. 1 test 2
    7. 3 test 3
    8. 3 test 1
    9. # uniq -d : 在文件中找出重复的行
    10. cat test.log | uniq -d
    11. # 输出结果:
    12. test 3
    13. test 1