The awk
below produces an output with the original header and only the matching lines (which is good), but the output where the original line numbering in the match found on is used. I can not figure out how to sequentially number the output instead of using the original.
I did try to add {$1=++n; print}
before the FNR==1
and though it executed the output was not correct. Thank you :).
file1
LYST NM_000081.3 chr1 235972867 235972867
MSH6 NM_000179.2 chr2 48027375 48027375
file2
R_Index Chr Start End Ref Alt Func.refGeneWithVer Gene.refGeneWithVer
1362 chr1 235972867 235972867 T C exonic LYST
5 chr1 985239 985239 C T splicing AGRN
1701 chr2 48027375 48027375 T C exonic MSH6
awk
awk -F'\t' 'NR==FNR{c[$1$3$4]++;next};c[$8$2$3] > 0; FNR==1' file1 file2
current output
R_Index Chr Start End Ref Alt Func.refGeneWithVer Gene.refGeneWithVer
1362 chr1 235972867 235972867 T C exonic LYST
1701 chr2 48027375 48027375 T C exonic MSH6
desired output
R_Index Chr Start End Ref Alt Func.refGeneWithVer Gene.refGeneWithVer
1 chr1 235972867 235972867 T C exonic LYST
2 chr2 48027375 48027375 T C exonic MSH6