2013-05-14 54 views
-3

我有兩個文件根據兩個文件之間的匹配創建一個新文件

第一個文件是這種格式。每行有唯一的ID開始(在這種情況下P22465)

P22465 DB DB; EC.31.1.1; the annexin (annexin) group. 

第二個文件是在這個format.Each符合(一些數)@ENTREZGENE開始

[email protected]|[email protected]|[email protected]|ANXA6:ANXA6|67 kDa calelectrin 

[email protected]|[email protected]|[email protected]|ACAA1:ACAA1|EC 2.3.1.16 

輸出應該是

[email protected]|[email protected]|[email protected]|ACAA1:ACAA1|EC 2.3.1.16 

它應該與第二個文件中包含唯一標識(P22465)的行匹配,並將整行復制到新文件中

+0

很酷。尼斯。什麼? :) – jm666 2013-05-14 13:45:58

+0

偉大的問題陳述。問題是什麼? – 2013-05-14 13:46:19

+0

複製哪一個文件的整行?請添加file2並輸出 – Kent 2013-05-14 13:55:24

回答

1

使用bash

fgrep -f <(awk '{print $1}' file1) file2 

這使用過程取代(<(...))。你也許可以這樣做,也是用:

awk '{print $1}' file1 | fgrep -f - file2 

這告訴fgrep「解讀從標準輸入匹配字符串」(-f -)。我沒有證實這是有效的,但我希望它能這樣做。

您可以使用grep -F代替fgrep(但Mac OS X有fgrep)。

相關問題