Retreive latest occurrence if there are multiple occurences

Hi All,

I need help to create an AWK code or Perl Code such that it will only extract the latest occurrence if there are multiple occurrences? Eg below.
Can any expert help ?

Input:

0013  28
0014   1
0013   1
0014   1
0017   1
0018  28
0017   1
0018   1
0019   1
0020  44

Output

0013   1
0014   1
0017   1
0018   1
0019   1
0020  44

Try this:

awk '{a[$1]=$0}END{for(i in a)print a}' file

Regards

Hi Franklin52,

Your code works!!
Thanks a million.

hi,

Below perl should also be ok.

open FH,"<a.txt";
foreach(<FH>){
	@tmp=split("	",$_);
	$hash{$tmp[0]}=$_;
}
for $key (sort keys %hash){
	print $hash{$key};
}
close FH;