How to match two fields


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to match two fields
# 8  
Old 04-26-2008
Base on your original post, you should find the most efficient player where RUN is the most important factor.

Code:
awk '
max<$2-$3      # Compare recordset efficiency score($2-$3) to max(higher efficiency score) value.
{
max=$2-$3      # If recordset has efficiency score greater that max, assign recordset efficiency score to max.
s=$0           # and assign the recordset to s variable.
}              # Loop until end of file.
END
{print s}      # At the end print the value of s, the recordset having the highest efficiency value.
'  data.file

I don't know but this questions look like a homework to me(check the forum rules).

Last edited by danmero; 04-26-2008 at 04:55 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match output fields agains two patterns

I need to print field and the next one if field matches 'patternA' and also print 'patternB' fields. echo "some output" | awk '{for(i=1;i<=NF;i++){if($i ~ /patternA/){print $i, $(i+1)}elif($i ~ /patternB/){print $i}}}' This code returnes me 'syntax error'. Pls advise how to do properly. (2 Replies)
Discussion started by: urello
2 Replies

2. UNIX for Beginners Questions & Answers

awk match two fields in two files

Hi, I have two TEST files t.xyz and a.xyz which have three columns each. a.xyz have more rows than t.xyz. I will like to output rows at which $1 and $2 of t.xyz match $1 and $2 of a.xyz. Total number of output rows should be equal to that of t.xyz. It works fine, but when I apply it to large... (6 Replies)
Discussion started by: geomarine
6 Replies

3. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

4. Shell Programming and Scripting

awk to calculate fields only if match is found

Trying to combine the matching $5 values between file1 and file2. If a match is found then the last $6 value in the match and the sum of $7 are outputted to a new file. The awk below I hope is a good start. Thank you :). file1 chr12 9221325 9221448 chr12:9221325-9221448 A2M 1... (5 Replies)
Discussion started by: cmccabe
5 Replies

5. Shell Programming and Scripting

Pattern Match and Rearrange the Fields in UNIX

For an Output like below Input : <Subject A="I" B="1039502" C="2015-06-30" D="010101010101"> Output : <Subject D="010101010101" B="1039502" C="2015-06-30" A="I"> I have been using something like below but not getting the desired output : awk -F ' ' '/Subject/ BEGIN{OFS=" ";}... (19 Replies)
Discussion started by: arunkesi
19 Replies

6. Shell Programming and Scripting

Match and subtract two fields

Not sure quite how to do this, but I am trying to use $1 of LCH.txt (exact match) to look for a match in $1 of genes.txt. If a match is found then in a new file match.txt $1 $2 ($4-$3) are copied. Example, the first record in LCH is PPT1 and that matches row 713, column 1 of genes.txt. ... (2 Replies)
Discussion started by: cmccabe
2 Replies

7. Shell Programming and Scripting

Add fields in different files only if some fields between them match

Hi everybody (first time posting here) I have a file1 that looks like > 1,101,0.1,0.1 1,26,0.1,0.1 1,3,0.1,0.1 1,97,0.5,0.5 1,98,8.1,0.218919 1,99,6.2,0.248 2,101,0.1,0.1 2,24,3.1,0.147619 2,25,23.5,0.559524 2,26,34,0.723404with 762 lines.. I have another 'similar' file2 > ... (10 Replies)
Discussion started by: murpholinox
10 Replies

8. Shell Programming and Scripting

how to match fields from different files in PERL

Howdy! I have multiple files with tab-separated data: File1_filtered.txt gnl|Amel_4.0|Group3.29 1 G R 42 42 60 15 ,.AAA.aa,aa.A.. hh00/f//hD/h/hh gnl|Amel_4.0|Group3.29 2 C Y 36 36 60 5 T.,T, LggJh gnl|Amel_4.0|Group3.29 3 A R 27 27 60 9 Gg,,.gg., B6hcc22_c File2_filtered.txt ... (3 Replies)
Discussion started by: sramirez
3 Replies

9. UNIX for Dummies Questions & Answers

Match values from 2 files and append certain fields

Hi, I need help on appending certain field in my file1.txt based on matched patterns in file2.txt using awk or sed. The blue color need to match with one of the data in field $2 in file2.txt. If match, BEGIN and FINISHED value in red will have a new value from field $3 and $4 accordingly. ... (1 Reply)
Discussion started by: redse171
1 Replies

10. Shell Programming and Scripting

Match two files and divide fields

I have two files that have the date field in common. I request your help with some script that divide each field value from file1 by the correspond field value of the file2 only when the field date is equal in both files. Thanks in advance ! This is a sample of the files file 1 12/16/2010,... (2 Replies)
Discussion started by: csierra
2 Replies
Login or Register to Ask a Question
NASH(1) 							   lrslib 0.42b 							   NASH(1)

NAME
nash - find nash equilibria of two person noncooperative games SYNOPSIS
setupnash input game1.ine game2.ine setupnash2 input game1.ine game2.ine nash game1.ine game2.ine 2nash game1.ine game2.ine DESCRIPTION
All Nash equilibria (NE) for a two person noncooperative game are computed using two interleaved reverse search vertex enumeration steps. The input for the problem are two m by n matrices A,B of integers or rationals. The first player is the row player, the second is the column player. If row i and column j are played, player 1 receives Ai,j and player 2 receives Bi,j. If you have two or more cpus available run 2nash instead of nash as the order of the input games is immaterial. It runs in parallel with the games in each order. (If you use nash, the program usually runs faster if m is <= n , see below.) The easiest way to use the program nash or 2nash is to first run setupnash or ( setupnash2 see below ) on a file containing: m n matrix A matrix B eg. the file game is for a game with m=3 n=2: 3 2 0 6 2 5 3 3 1 0 0 2 4 3 % setupnash game game1 game2 produces two H-representations, game1 and game2, one for each player. To get the equilibria, run % nash game1 game2 or % 2nash game1 game2 Each row beginning 1 is a strategy for the row player yielding a NE with each row beginning 2 listed immediately above it.The payoff for player 2 is the last number on the line beginning 1, and vice versa. Eg: first two lines of output: player 1 uses row probabilities 2/3 2/3 0 resulting in a payoff of 2/3 to player 2.Player 2 uses column probabilities 1/3 2/3 yielding a payoff of 4 to player 1. If both matrices are nonnegative and have no zero columns, you may instead use setupnash2: % setupnash2 game game1 game2 Now the polyhedra produced are polytopes. The output of nash in this case is a list of unscaled probability vectors x and y. To normalize, divide each vector by v = 1^T x and u=1^T y.u and v are the payoffs to players 1 and 2 respectively. In this case, lower bounds on the payoff functions to either or both players may be included. To give a lower bound of r on the payoff for player 1 add the options to file game2 (yes that is correct!)To give a lower bound of r on the payoff for player 2 add the options to file game1 minimize 0 1 1 ... 1 (n entries to begiven) bound 1/r; ( note: reciprocal of r) If you do not wish to use the 2-cpu program 2nash, please read the following. If m is greater than n then nash usually runs faster by transposing the players. This is achieved by running: % nash game2 game1 If you wish to construct the game1 and game2 files by hand, see the lrslib user manual[1] SEE ALSO
For information on H-representation file formats, see the man page for lrslib or the lrslib user manual[2] NOTES
1. lrslib user manual http://cgm.cs.mcgill.ca/%7Eavis/C/lrslib/USERGUIDE.html#Nash%20Equilibria 2. lrslib user manual http://cgm.cs.mcgill.ca/%7Eavis/C/lrslib/USERGUIDE.html#File%20Formats July 2009 03/30/2011 NASH(1)