View Single Post

  #1 (permalink)  
Old 03-19-2008, 10:10 PM
Prahlad Prahlad is offline
Junior Member
User
 
Join Date: Feb 2008
My distro: Debian
Posts: 5
Rep Power: 0
Prahlad is on a distinguished road
Default How to match two fields

Hello All,

I need a urgent help regarding one issue here.

Let me explain the problem.

I have a file "player" which contains three players with their RUN and ECONOMY rate.

----------
Name Run Economy
David 23 8
stuart 12 12
string 33 4
-----------

Now i want to find best player who has highest run but lowest economy rate.

Means according to this file best player shud be "string".

How i proceed ...

first i took highest run and lowest economy in a variables (i and j).

i=`cat player | awk 'BEGIN { FS= " " } {print $2}' | grep -v Run | sort -nr | head -1`

---------
bash-3.1$ echo $i
33
------


j=`cat player | awk 'BEGIN { FS= " " } {print $3}' | grep -v Economy | sort -n | head -1`

---------
bash-3.1$ echo $j
3
bash-3.1$
----------

Now the problem is how to match two fields that am not sure.

Plzzz help me .. :
Reply With Quote