Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to sort following 1

Status
Not open for further replies.

bolobaboo

MIS
Aug 4, 2008
120
US
I have a file with following entry ...
example ..
gvpw128 000:10:34 1278
gvpw129 002:51:50 26798
gvpw129 000:10:23 1279
gvpw129 001:01:35 8163
gvpw129 000:08:06 1046
gvpw132 005:44:51 62332
gvpw132 000:40:38 5336
gvpw132 001:04:00 8309
gvpw132 000:10:27 1284

i need following output , checks last collomon whichever has largest number print only that line.
gvpw128 000:10:34 1278
gvpw129 002:51:50 26798
gvpw132 005:44:51 62332
 
One way:
Code:
awk '$3>n[$1]{n[$1]=$3;x[$1]=$0;s[r++]=$1}END{for(i=0;i<r;++i)print x[s[i]]}' /path/to/input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi
PHV
I am newbee ...can you elaboate above awk suggestion ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top