我想丢弃由另一个文件调节的一个文件的行,条件由它们共享的两列设置。这意味着我想丢弃file_1的行,在另一个文件(file_2)中共享的两个公共列(第2列和第3列)中使用相同的值。
我想使用join
命令来做到这一点,但是,我失败了。
# The command I used:
join -j 2 -j 3 -a 2 file_2.txt file_1.txt
你能指出我的错误并帮我纠正吗?而且,我想知道如何使用Awk脚本完成这项工作。
# the two files are **tab-delimited**, and the key fields used to join are **column 2** and **column 3** in
# these two files.
**# file_1.txt**
AL3C3P1-4 1 1 T T 1 1 1 1
AL3C3P1-4 1 2 C A 1 1 1 1
AL3C3P1-4 1 3 A A 1 1 1 1
AL3C3P1-4 1 4 C C 1 2 1 1
AL3C3P1-4 1 5 T T 2 3 1 1
AL3C3P1-4 1 6 T T 2 5 1 1
AL3C3P1-4 1 7 T T 2 6 1 1
AL3C3P1-4 1 8 C C 3 9 1 1
AL3C3P1-4 1 9 A A 3 8 1 1
AL3C3P1-4 1 10 C - 3 10 1 1
AL3C3P1-4 1 11 T T 6 11 1 1
AL3C3P1-4 1 12 T - 6 11 1 1
AL3C3P1-4 1 13 C - 8 13 1 1
AL3C3P1-4 1 14 T - 10 15 1 1
AL3C3P1-4 1 15 G G 12 15 1 1
AL3C3P1-4 1 16 G G 12 16 1 1
AL3C3P1-4 1 17 A A 14 18 1 1
AL3C3P1-4 1 18 T T 14 19 1 1
AL3C3P1-4 1 19 G G 14 18 1 1
AL3C3P1-4 1 20 C C 14 22 1 1
**# file_2.txt**
AL3C3P1-4 1 1 T T 1 1 1 1
AL3C3P1-4 1 2 C A 1 1 1 1
AL3C3P1-4 1 3 A A 1 1 1 1
AL3C3P1-4 1 4 C C 1 2 1 1
AL3C3P1-4 1 10 C - 3 10 1 1
AL3C3P1-4 1 11 T T 6 11 1 1
AL3C3P1-4 1 12 T - 6 11 1 1
AL3C3P1-4 1 13 C - 8 13 1 1
AL3C3P1-4 1 14 T - 10 15 1 1
AL3C3P1-4 1 15 G G 12 15 1 1
AL3C3P1-4 1 16 G G 12 16 1 1
AL3C3P1-4 1 17 A A 14 18 1 1
AL3C3P1-4 1 18 T T 14 19 1 1
AL3C3P1-4 1 19 G G 14 18 1 1
AL3C3P1-4 1 20 C C 14 22 1 1
答案 0 :(得分:4)
$ awk 'FNR==NR{a[$2$3];next} (!($2$3 in a))' file2 file1
AL3C3P1-4 1 5 T T 2 3 1 1
AL3C3P1-4 1 6 T T 2 5 1 1
AL3C3P1-4 1 7 T T 2 6 1 1
AL3C3P1-4 1 8 C C 3 9 1 1
AL3C3P1-4 1 9 A A 3 8 1 1