uniq用法

测试文件如下

$cat myfile.txt

May Day
May Day
May Day
Going Down
May Day

uniq -u d c -f input-file output-file

-u  只显示不重复行

-d  只显示有重复数据行,每种重复行只显示其中一行

-c  打印每一重复行出现次数

-f  n为数字,前n个域被忽略

$uniq myfile.txt

May Day
Going Down
May Day

去除了连续的重复行

$uniq -u myfile.txt

May Day
Going Down

只显示不重复行

打印每个不重复行,并显示行号

$uniq -c parts.txt

  3 May Day
      1 Going Down
      1 May Day

原文地址:https://www.cnblogs.com/djcsch2001/p/2039383.html