我正在尝试查找file1
中未找到的file2
下方的行。下面的awk
会运行,但不会产生任何结果。谢谢你:)。
文件1
955763
957852
976270
file2的
chr1 955543 955763 chr1:955543-955763 AGRN-6|gc=75
chr1 957571 957852 chr1:957571-957852 AGRN-7|gc=61.2
chr1 970621 970740 chr1:970621-970740 AGRN-8|gc=57.1
所需的输出
2 ids found
976270 missing
awk (missing.awk)
BEGIN { FS="[[:space:]]+|-" }
NR == FNR { seen[$0]; next }
$3 in seen { found[$3]; delete seen[$6] }
END { print length(found) " ids found"
for (i in seen) print i " missing" }
awk -f missing.awk file1 file2
答案 0 :(得分:2)
awk
救援!
如果file2大小比file1大得多,这种方法更好
awk 'NR==FNR{a[$1];next}
$3 in a{c++; delete a[$3]}
END{if(c) print c " ids found";
for(k in a) print k " missing"}' file1 file2
2 ids found
976270 missing