Find match between two datasetsand add value


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find match between two datasetsand add value
# 1  
Old 05-08-2014
Find match between two datasetsand add value

Dear all, could you help with following:
i have two large datasets that contain two columns.
dataset1:
Code:
752566    rs3094315
752721    rs3131972
753541    rs2073813
760300    rs11564776
768448    rs12562034
776546    rs12124819

dataset2:
Code:
55550 0.000000
82571 0.080572
88169 0.092229
254996 0.439456

If number from 1st column of dataset1 match to the number in 1st column of the dataset2, I have to embed corresponding 'rs' value from dataset1 to dataset2 as a third column.

Thank u a lot for ur help and suggestions!
# 2  
Old 05-08-2014
Code:
 awk 'FNR==NR {f1[$1]=$2;next} $1 in f1 {$0=$0 OFS f1[$1]}1' dataset1 dataset2

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 05-08-2014
Just to clarify, your sample data contains no matches at all correct? None of the numbers in the first column of your first file match any of the numbers in the first column of your second file.
# 4  
Old 05-08-2014
to pilnet101:

I know, that between dataset1 and dataset2 there are around 60.000 matches between numbers in the first columns. Number of rows in both datasets is different. So, I need to 'embed' rs number from dataset1 to corresponding physical position (number in 1st column of dataset2) into dataset2.

---------- Post updated at 07:33 PM ---------- Previous update was at 07:04 PM ----------

to vgersh99 :
thank u a lot for quick solution!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Match file and find count

Hi All, I have transaction in one file.I want to match that to another file and find the number of time the transaction is available on the other file.I need to take each record from TRANSFILE and match that with SPEND FILE and find the number of counts of the transaction TRANSFILE: ... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

2. Shell Programming and Scripting

Find the exact and best match between 2 files

Dear Forum, File1: Reference 4474189 United Kingdom Mobile 4474188 United Kingdom Mobile 4474187 United Kingdom Mobile 447 United Kingdom 93 AFGHANISTAN 0093 1907 ALASKA 001907 355 ALBANIA 00355 35568 ALBANIA MOBILE 0035568 35569 ALBANIA MOBILE 0035569 213 ALGERIA 00213 2137 ALGERIA... (2 Replies)
Discussion started by: yahyaaa
2 Replies

3. Shell Programming and Scripting

Find sessionids after match

Hi Guys, I need a help on writing shell scripting where I am stuck on finding keyword after a grep match. file.log (sample) line1 -> ppp dfasf adgasg session out sfsgsgsghsgh line2 -> sdaf agasg sessionid: 1234Nhsh34 sdagsjhsh srhs line3 -> sdgshytnba sessionid: 453omgt thdjdh gfhjdj... (19 Replies)
Discussion started by: TCS
19 Replies

4. Shell Programming and Scripting

Use of sed to find everything after first match!

Hi Guys So far I have got this to work: set x = temp1:temp2:temp3 echo $x | sed 's/.*:\(.*\).*/\1/' Answer: temp3 But I want answer as temp2:temp3, that is everything after the first ":" is found. If anybody can help with a bit of description that will be great. Thanks in Advance (1 Reply)
Discussion started by: dixits
1 Replies

5. Shell Programming and Scripting

Help me with s script to find exact match

Hi, im extracting data from oracle DB. As the data is case sensitive, i have to extract the data which doesn't match exactly. im poor in unix scripting, can someone plz help me with a script. Here are the details. Need to compare the second column of the each line of the file1.csv with the data in... (5 Replies)
Discussion started by: JSKOBS
5 Replies

6. Shell Programming and Scripting

Find out match characters on all lines

I have a file with 22 lines. Each line has only 5 different chars, no white space, and each line is 3,278,824 in length. The 5 chars is "-", "A", "B", "C", "D". Below is an example of the first 25 chars of the first four lines of the file. -----ABCDA--CD-BBBBB----D --A--ABCD--DCD-BBBBC-----... (12 Replies)
Discussion started by: cwzkevin
12 Replies

7. Shell Programming and Scripting

Match look up file and find result

Hi I ahve a lookup file wiht seven words CD HT CAD HT T1D T2D BDanother file contain data like this CHRM1 P11229 Pirenzepine DAP000492 Peptic ulcer disease Approved T2D CHRM1 P11229 Glycopyrrolate DAP001116 Anesthetic Approved T2D CHRM1 P11229 ... (7 Replies)
Discussion started by: manigrover
7 Replies

8. Shell Programming and Scripting

Find out the match data content?!

Hi, Long list of Input file1 content: 1285_t 4860_i 4817_v 8288_c 9626_a . . . Long list of Input file2 content: 1285_t chris germany 8288_c steve england 9626_a dave swiss 9260_s stephanie denmark . . . (14 Replies)
Discussion started by: patrick87
14 Replies

9. Shell Programming and Scripting

find: No match due to find command being argument

I am using csh and getting the error "find: No match." but I cannot figure out why. What I am trying to do is set the find command to a variable and then execute the variable as a command. I ran it through a debugger and it looks like $FIND is getting set but the find command can not actually be... (2 Replies)
Discussion started by: mst3k4l
2 Replies

10. Shell Programming and Scripting

How to find first match and last match in a file

Hi All, I have a below file: ================== 02:53 pravin-root 02:53 pravin-root 03:05 pravin-root 02:55 pravin1-root 02:59 pravin1-root ================== How do I find the first and last value of column 1. For example, how do I find 02:53 is the first time stamp and 03:05 is... (3 Replies)
Discussion started by: praving5
3 Replies
Login or Register to Ask a Question