![]() |
|
|
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 |
|
|
|
||||
|
Code:
awk '{
if($2>_[$1])
_[$1]=$2
}
END{
for(i in _)
print i,_[i]
}' a.txt
Code:
#!/usr/bin/perl
open FH,"<a.txt";
while(<FH>){
chomp;
my @temp=split(" ",$_);
$arr{$temp[0]}=$temp[1] if ($temp[1] > $arr{$temp[0]});
}
for $k (keys %arr){
print $k," ",$arr{$k},"\n";
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|