The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-15-2008
Tytalus's Avatar
Tytalus Tytalus is offline
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 297
The neat nawk solution will not always provide the same solution independent of line ordering though...

something like:

Code:
awk '{if ( length($0) > length(a[$1]) ) {a[$1]=$0}} END {for (i in a){print a[i]}}' file
will ensure you get the longest line (if that is a requirement).
Reply With Quote