The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 02-11-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
max[$1] = !($1 in max) ? $2 : ($2 > max[$1]) ? $2 : max[$1]
max[$1] - 'max' is an array indexed by the value of the FIRST field
!($1 in max) ? $2 - if '$1' is NOT already in array 'max', return the value of the SECOND field
: - otherwise
($2 > max[$1]) ? $2 : max[$1]
if the value of the SECOND field is greater than what's already in array 'max' (index by '$1'), return the value of the SECOND field. If not, return the current value of array 'max[$1]'.

'max[$1] =' - whatever gets returned, store it array 'max' index by the FIRST field.

Lil' bit wordy, but I hope you get the gist of it.

Last edited by vgersh99; 02-12-2009 at 07:31 AM..