fork(1) download
  1. BEGIN { FS = "|" }
  2. ! ($2 in students) {
  3. students[$2] = $1
  4. scores[$2] = $3 }
  5. $2 in students {
  6. if ($1 < students[$2]) {
  7. students[$2] = $1
  8. scores[$2] = $3 } }
  9. END { for (s in scores)
  10. print s, scores[s] }
Success #stdin #stdout 0s 5884KB
stdin
22|Math|45
23|English|52
22|English|51
26|Math|72
23|Math|61
21|English|81
stdout
Math 45
English 81