开发者

Return list of triplicates

开发者_JAVA百科

To find duplicates you can use

sort | uniq -d

but is there a quick way to find triplicates?


You can use:

sort | uniq -c | awk '$1 == 3'

uniq -c gives you a count of occurences in the first column. The awk line filters all lines with has 3 in the first column.

If you want all items occuring 3 or more times write $1 >= 3

You can also pick out just the items names with (if they are just one column with no spaces) with:

sort | uniq -c | awk '$1 >= 3 {print $2}'

Ans so on ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜