Sort and deduplicate lines by a field

Bash

Sorts on the second column and keeps the first row of each group.

sort -t',' -k2,2 -u contacts.csv

# Count duplicates instead of removing them:
cut -d',' -f2 contacts.csv | sort | uniq -c | sort -rn

More in Text Processing

Random picks