-3

I have one CSV file:

ID;CREATED_AT;CITY
42;2015-05-25 14:27:29;Delhi
33;2015-05-11 09:07:37;London
453;2015-05-22 14:27:29;Delhi
33;2015-05-12 09:07:37;Kolkata
453;2015-05-24 14:27:29;Bangalore
42;2015-05-26 14:27:29;Delhi
453;2015-05-21 14:27:29;Bangalore

I want the output like:

ID;CREATED_AT;CITY
33;2015-05-12 09:07:37;Kolkata
42;2015-05-26 14:27:29;Delhi
453;2015-05-24 14:27:29;Bangalore

Logic: Output should have uniq ID with the data having latest CREATED_AT. Good if File is sorted based on ID. Linux command is preferred.

user1735076
  • 3,225
  • 7
  • 19
  • 16
  • 1
    "Linux command is preferred"??? This is not a coding service, even though going through your questions suggests you are using it as so (no feedback, no accepting...). Better post your attempts. – fedorqui Nov 25 '15 at 13:45

1 Answers1

0
awk -F ';' 'NR==1{print;next}{a[$1]=$0}END{for(i in a)print a[i]}' file
ID;CREATED_AT;CITY
33;2015-05-12 09:07:37;Kolkata
42;2015-05-26 14:27:29;Delhi
453;2015-05-21 14:27:29;Bangalore
bian
  • 1,456
  • 8
  • 7