04-12-2008
How to match two fields
Hello Every one,
I am in need of all ur's help.
Let me straight explain the problem ..
I have a file "player" which contains three players with their NAME , 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".
I did try writing script but that does not work when i change the data .
What is did is :
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 ..
( i tried fgrep but it does not work ).
Please help me out with this.
Thanks,
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. UNIX for Dummies Questions & Answers
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
9. UNIX for Beginners Questions & Answers
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
10. Shell Programming and Scripting
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
LEARN ABOUT DEBIAN
jsymphonic
JSYMPHONIC(1) General Commands Manual JSYMPHONIC(1)
NAME
jsymphonic - File manager for Sony's MP3 players
SYNOPSIS
jsymphonic
DESCRIPTION
jsymphonic manages files stored on a Sony MP3 player plugged onto the computer.
Important note: The MP3 player should be mounted first ! You might want to use pmount(1) to mount it without needing root privileges.
The first time it is run, jsymphonic will ask you in which directory the MP3 player is mounted. This directory should not change, or you
will need to configure it again. If jsymphonic complains that it cannot find the OMGAUDIO folder, it means that either the music player is
not mounted, either the path of the player has not been set yet. If that is the case, set it using the JSymphonic/Properties menu item.
JAVA-WRAPPERS NOTE
This program is a shell script wrapper based on java-wrappers(7). You therefore benefit from several features; please see the java-wrap-
pers(7) manual page for more information about them.
SEE ALSO
pmount(1) and java-wrappers(7)
AUTHOR
This manual page was written by Vincent Fourmond <fourmond@debian.org> from the Debian project, but may be used by others.
26-01-2009 JSYMPHONIC(1)