Sample Header Ad - 728x90

print all max values in text file using awk

1 vote
2 answers
141 views
I'm trying to print out all the max values in one column So the input looks like this
John.      Marketing.   5000.  
Marcus.    Manager.     9500.  
Jason.     SW           9500.  
Cindy.     Developer.   6000.
the output I want is
name: Marcus, sal: 9500.    
   name: Jason, sal: 9500
so far, my code is
BEGIN {a=0}

    {
        if ($3> a)
           max=$3;
        output=$1
     }

    END{
      print "name: ", output, "sal:", max
    }
Asked by wannabe (11 rep)
Nov 16, 2022, 03:58 AM
Last activity: Nov 17, 2022, 05:23 AM