Hi All,
I am trying to join to files based on one common column.
Cat File1
ID HID
Ab_1 23
Cd 45
df 22
Vv 33
Cat File2
ID pval
Ab_1 0.3
Cd 10
Vv 0.0444
(file1 has 18,000 rows and file 2 have between 4,000 to 8,000 rows)
Desired output:
Cat Fileout
HID pval
23 0.3
10 45
33 0.0444
By searching the forum, I came up with this script:
awk ' FNR == NR { ab[$1] = $2 } FNR != NR { cd[$1] = $2 } END { for (a in ab) if (a in cd) print ab[a],cd[a] }' FS='\t' OFS='\t' File1 File2 >Fileout
It seems to work fine in the beginning. But when I used it in large file with 15,000 rows it is giving errors (eg. missing some rows).
I am a beginner in scripting. I am not sure if there is error in above script or if there is a better way to do this. Any suggestion will be very helpful.
Thank you for your time,
NP