3

I use sort -r | head and get the out put like this:

  8 a1
  8 a2
  5 a3
  5 a4
  4 a5
  4 a6
  4 a7
  4 a8
  4 a9
  4 a0

What can I do to make the output like this:

  8 a1
  8 a2

only the largest k1 number show up????

Adrian Heine
  • 4,051
  • 2
  • 30
  • 43
Sal Kuk
  • 53
  • 4

1 Answers1

3

There are several ways to do it, but here is one using awk. Since it is already sorted, you want to check to just print lines that match the first value by piping the headed list into something like

awk 'BEGIN{maxval=0}; (maxval==0) {maxval=$1}; ($1==maxval) {print $0}'
cm2
  • 1,815
  • 15
  • 20