파일 1
Name,TaxID,Lineage,Count,Proportion_All(%),Proportion_Classified(%)
Acaryochloris marina,155978,Bacteria;Cyanobacteria;;Synechococcales;Acaryochloridaceae;Acaryochloris,4,0.000218669,0.00120249
Anabaena cylindrica,1165,Bacteria;Cyanobacteria;;Nostocales;Nostocaceae;Anabaena,9,0.000492005,0.00270561
파일 2
Object_ID, Length, Assignment
NODE_1_length_501653_cov_19.284,501653,1727163
NODE_2_length_458856_cov_17.1812,458856,374606
NODE_3_length_369230_cov_19.3769,369230,1727163
NODE_4_length_342860_cov_16.7318,342860,83263
NODE_5_length_301494_cov_19.1256,301494,1727163
NODE_6498_length_5833_cov_14.8079,5833,155978
NODE_6499_length_5833_cov_4.85133,5833,NA
NODE_6500_length_5831_cov_23.1697,5831,553814
NODE_6501_length_5831_cov_22.403,5831,795665
산출
Object_ID, Length, Assignment
NODE_6498_length_5833_cov_14.8079,5833,155978
File 1의 두 번째 열에 있는 ALl 값은 File 2의 마지막 배열에 있는 텍스트와 일치하며, 발견되면 File 2가 인쇄됩니다.
답변1
awk를 사용하세요:
awk -F, 'NR==FNR {TaxID[$2]=1; next} FNR==1 || $NF in TaxID' File1 File2
Object_ID, Length, Assignment
NODE_6498_length_5833_cov_14.8079,5833,155978