perl -ne'print "$.\t$_"' input.txt \ | sort -k 2 \ | uniq -f 1 \ | sort \ | cut -f 2- \ > output.txt