perl -n -e "chomp; /(\d+)$/; print $1 unless $hash{$_}; $hash{$_}++;" infile>outfile