![]() |
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to sort a file and then print similar lines once | shira | Shell Programming and Scripting | 6 | 01-27-2009 01:22 PM |
| Sort, group rows | patrykxes | Shell Programming and Scripting | 6 | 01-06-2009 02:28 PM |
| awk help required to group output and print a part of group line and original line | rajan_san | Shell Programming and Scripting | 5 | 10-27-2008 09:16 AM |
| Sort cmd to get GROUP BY? | RacerX | UNIX for Dummies Questions & Answers | 6 | 10-16-2008 08:40 AM |
| PHP & MySQL: sort desending and print | perleo | Shell Programming and Scripting | 1 | 09-02-2003 12:50 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
awk - sort, then print the high value for each group
Hi @ all
I'm trying to achive to this problem, I've a 2-column composed file as the following: 192.168.1.2 2 192.168.1.3 12 192.168.1.2 4 192.168.1.4 3 cpc1-swan1-2-3-cust123.swan.cable.ntl.com 4 192.168.1.3 5 192.168.1.2 10 192.168.1.4 8 cpc1-swan1-2-3-cust123.swan.cable.ntl.com 8 and i would this kind of output : 192.168.1.2 10 192.168.1.3 12 192.168.1.4 8 cpc1-swan1-2-3-cust123.swan.cable.ntl.com 8 I'm trying to use this methodology : Code:
awk '{ a[$NF]=$2; if ( a[$NF] >= max[$NF] ) max[$NF]=a[$NF] } END { for ( item in a ) print item,max[item] }'
but i'm not sure this is the right way.... Thanks you all in advance!!! m4rco- |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|