perl -ne "next if $seen{$_}++;print" a.txt | sort >b.txt