Pages

lundi 16 janvier 2012

remove duplicate lines in linux

Always starting with sort, then uniq command. 

Attention: uniq -d to only print duplicate lines, and uniq -u to only print unique lines

Given data.txt
79417701
79417701
79417701
88341001
88341001
88341001
88341001

cat data.txt | sort | uniq -d to print
79417701
88341001


cat data.txt | sort | uniq -u to print
blank

Aucun commentaire:

Enregistrer un commentaire