Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Join 基于两列比较文件_Join_Awk_Merge_Grep_Compare - Fatal编程技术网

Join 基于两列比较文件

Join 基于两列比较文件,join,awk,merge,grep,compare,Join,Awk,Merge,Grep,Compare,我有两个包含数千行的文件: 文件1: COL22A1 LCT 1 12 0.149667616334 2.16226378401 GPRIN2 TP53 12 170 0.0455368539793 44.2359753827 MUC3A TP53 12 170 0.0455368539793 44.2359753827 文件2: COL22A1 LCT 12 41 23 0.0296296296296 0.101234567901 0.0567901234568 2.36563

我有两个包含数千行的文件:

文件1:

COL22A1 LCT 1 12    0.149667616334  2.16226378401
GPRIN2 TP53 12 170  0.0455368539793 44.2359753827
MUC3A TP53 12 170   0.0455368539793 44.2359753827
文件2:

COL22A1 LCT 12 41 23 0.0296296296296 0.101234567901 0.0567901234568 2.36563
MEGF10 SORCS1 10 21 39 0.0246913580247 0.0518518518519 0.0962962962963 2.30599
我想比较这些文件的前两列,如果它们匹配,我想打印第二个文件的整行和第一个文件的最后一列:

输出:

COL22A1 LCT 12 41 23 0.0296296296296 0.101234567901 0.0567901234568 2.36563 2.16226378401

我试过awk、grep、join,但它总是只给我一个文件的输出,你能试一下下面的内容并让我们知道吗

awk 'FNR==NR{a[$1,$2]=$NF;next} a[$1,$2]{print $0,a[$1,$2]}' Input_file1  Input_file2

请您尝试以下内容,然后让我们知道

awk 'FNR==NR{a[$1,$2]=$NF;next} a[$1,$2]{print $0,a[$1,$2]}' Input_file1  Input_file2