![]() |
|
|
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 |
| Script move and rename based on matching criteria | braidomik | Shell Programming and Scripting | 3 | 08-26-2008 12:35 PM |
| I cant updated the score on space invaders | lo-lp-kl | Post Here to Contact Site Administrators and Moderators | 0 | 06-26-2008 02:35 PM |
| Remove lines, Sorted with Time based columns using AWK & SORT | karthikn7974 | Shell Programming and Scripting | 1 | 05-10-2008 12:04 AM |
| Remove files based on date | hshapiro | UNIX for Dummies Questions & Answers | 4 | 12-09-2005 12:21 PM |
| Select records based on search criteria on first column | shashi_kiran_v | UNIX for Dummies Questions & Answers | 2 | 12-02-2005 01:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi guys,
Please guide for Solution. PART-I INPUT FILE (has 2 columns ID and score) TC5584_1 93.9 DV161411_2 79.5 BP132435_5 46.8 EB682112_1 34.7 BP132435_4 29.5 TC13860_2 10.1 OUTPUT FILE (It shudn't contain the line ' BP132435_4 29.5 ' as BP132435 is repeated and it has lower score. If an ID is repeated more than twice, one with highest score should remain) TC5584_1 93.9 DV161411_2 79.5 BP132435_5 46.8 EB682112_1 34.7 TC13860_2 10.1 PART-II ====FILE1====== TC5584_1 93.9 DV161411_2 79.5 BP132435_5 46.8 EB682112_1 34.7 TC13860_2 10.1 =====FILE2====== EB681299_3 129 269 EB425502_1 71 182 TC5584_1 66 188 BP132435_5 37 106 EB682112_1 22 150 BP132435_4 117 175 TC13860_2 16 93 DV161411_2 36 239 ===OUTPUT_FILE===== (It contains column1 from FILE1 and its corresponding row from FILE2) TC5584_1 66 188 DV161411_2 36 239 BP132435_5 37 106 EB682112_1 22 150 TC13860_2 16 93 your help is highly appreciated. Thanks in advance. ![]() Last edited by smriti_shridhar; 12-01-2008 at 07:22 AM.. Reason: formating |
|
||||
|
Try: Part 1: Code:
for each in $(awk -F"_" '{ print $1; }' input_file | sort -u); do sort -k1,1 -k2n input_file | grep $each | tail -1 >>output; done
For Part 2: Code:
for each in $(awk -F"_" '{ print $1; }' file1 | sort -u); do sort -k1,1 -k2n file2 | grep $each | tail -1 >>output; done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|