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 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With