【发布时间】:2019-11-19 03:04:49
【问题描述】:
我有file_1
BlockID
VT11742
VT11744
VT11050
VT11870
VT12147
VT12149
VT12176
VT12180
和文件_2
AB Ref2 VICTOR
crc_31-C1 VT11929
crc_31-C2 VT11929 C2
crc_31-N VT11929 NORMAL
crc_32-C1 VT11050
crc_32-C2 VT11050 C2
crc_33-C1 VT11656
crc_33-C2 VT11656 C2
crc_33-N VT11656 NORMAL
crc_34-C1 VT11981
crc_34-C2 VT11981 C2
我想要的输出是当 file1 的第一列与 file2 匹配时打印出 file2 的第一列,并以与 file2 相同的顺序打印出来,并在“不匹配”时打印
输出
BlockID
VT11742 no_match
VT11744 no_match
VT11050 crc_32-C1
VT11870 no_match
VT12147 no_match
VT12149 no_match
VT12176 no_match
VT12180 no_match
我以为我可以做这样的事情 grep -Ff file1 file2 > 输出
【问题讨论】:
-
您说您想要
print out in the same order of file2,但这不是您在预期输出中显示的内容。请修正您的问题以保持一致/准确。还要在file1中包含VT11929,这样当file2中有多个匹配项时,我们可以看到预期的输出。
标签: unix join awk grep pattern-matching