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
MONOP(6)							   Games Manual 							  MONOP(6)

NAME
monop - Monopoly game SYNOPSIS
/usr/games/monop [ file ] DESCRIPTION
Monop is reminiscent of the Parker Brother's game Monopoly, and monitors a game between 1 to 9 users. It is assumed that the rules of Mo- nopoly are known. The game follows the standard rules, with the exception that, if a property goes up for auction and there are only two solvent players, no auction is held and the property remains unowned. The game, in effect, lends the player money, so it is possible to buy something which you cannot afford. However, as soon as a person goes into debt, he must "fix the problem", i.e., make himself solvent, before play can continue. If this is not possible, the player's property reverts to his debtee, either a player or the bank. A player can resign at any time to any person or the bank, which puts the property back on the board, unowned. Any time that the response to a question is a string, e.g., a name, place or person, you can type `?' to get a list of valid answers. It is not possible to input a negative number, nor is it ever necessary. A Summary of Commands: quit: quit game: This allows you to quit the game. It asks you if you're sure. print: print board: This prints out the current board. The columns have the following meanings (column headings are the same for the where, own holdings, and holdings commands): Name The first ten characters of the name of the square Own The number of the owner of the property. Price The cost of the property (if any) Mg This field has a `*' in it if the property is mortgaged # If the property is a Utility or Railroad, this is the number of such owned by the owner. If the property is land, this is the number of houses on it. Rent Current rent on the property. If it is not owned, there is no rent. where: where players are: Tells you where all the players are. A `*' indicates the current player. own holdings: List your own holdings, i.e., money, get-out-of-jail-free cards, and property. holdings: holdings list: Look at anyone's holdings. It will ask you whose holdings you wish to look at. When you are finished, type "done". shell: shell escape: Escape to a shell. When the shell dies, the program continues where you left off. mortgage: mortgage property: Sets up a list of mortgageable property, and asks which you wish to mortgage. unmortgage: unmortgage property: Unmortgage mortgaged property. buy: buy houses: Sets up a list of monopolies on which you can buy houses. If there is more than one, it asks you which you want to buy for. It then asks you how many for each piece of property, giving the current amount in parentheses after the property name. If you build in an unbalanced manner (a disparity of more than one house within the same monopoly), it asks you to re-input things. sell: sell houses: Sets up a list of monopolies from which you can sell houses. It operates in an analogous manner to buy. card: card for jail: Use a get-out-of-jail-free card to get out of jail. If you're not in jail, or you don't have one, it tells you so. pay: pay for jail: Pay $50 to get out of jail, from whence you are put on Just Visiting. Difficult to do if you're not there. trade: This allows you to trade with another player. It asks you whom you wish to trade with, and then asks you what each wishes to give up. You can get a summary at the end, and, in all cases, it asks for confirmation of the trade before doing it. resign: Resign to another player or the bank. If you resign to the bank, all property reverts to its virgin state, and get-out-of-jail free cards revert to the deck. save: save game: Save the current game in a file for later play. You can continue play after saving, either by adding the file in which you saved the game after the monop command, or by using the restore command (see below). It will ask you which file you wish to save it in, and, if the file exists, confirm that you wish to overwrite it. restore: restore game: Read in a previously saved game from a file. It leaves the file intact. roll: Roll the dice and move forward to your new location. If you simply hit the <RETURN> key instead of a command, it is the same as typing roll. AUTHOR
Ken Arnold FILES
/usr/games/lib/cards.pck Chance and Community Chest cards BUGS
No command can be given an argument instead of a response to a query. 4th Berkeley Distribution May 6, 1986 MONOP(6)