nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

How to match two fields

This is a discussion on How to match two fields within the Shell scripting forums, part of the Development/Scripting category; Hello All, I need a urgent help regarding one issue here. Let me explain the problem. I have a file &...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-19-2008, 09:10 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: Debian
Posts: 5
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
  #2 (permalink)  
Old 03-20-2008, 12:28 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: Debian
Posts: 5
Prahlad is on a distinguished road
Default

I guess i was not clear with my question .......
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 12:48 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: fedora
Posts: 25
chandanperl is on a distinguished road
Default How to match two fields

Hi
would u like to get solution in perl
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 12:58 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: Debian
Posts: 5
Prahlad is on a distinguished road
Default Yes please

Thank u very much for ur reply ...

YEs PLeaseeeeany solution will do.

Also it ud b better if u can explain me a bit ... Please

Thank u very much
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
match the columns of 2 files and merge common rows piyali_biobase Shell scripting 0 11-05-2007 06:34 PM
diff command to exclude files that match pattern piggy Getting started tutorials 1 08-13-2007 10:52 PM
Sorting individual records in a file based on some fields cucu81 Shell scripting 1 07-25-2006 03:08 AM


All times are GMT +5.5. The time now is 04:51 PM.


Powered by vBulletin® Version 3.7.2 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35