0

I have a input like this ; i need to filter the greater record value

cat;5
dog;3
bird;2
cat;3
dog;6
bird;8

for output a result like this

cat;5
dog;6
bird;8

1

1 Answer 1

1

Please try the following:

#!/usr/bin/awk -f

BEGIN {
  FS = OFS = ";";
}

{
  if($2 > a[$1]) { a[$1] = $2 }
  else { a[$1] = $2 }
}

END {
  for(x in a) { print x, a[x] }
}
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.