how to do join of two files conditioned by two columns, by using join command and awk script
I would like to discard rows of one file conditioned by the other file, with the condition is set by the two columns they shared. This means I want to discard the rows of file_1, with the same values in the two common columns (columns 2 and 3) shared in the other file (file_2).
I want to use join
command to do that, But, I failed.
# The command I used:
join -j 2 -j 3 -a 2 file_2.txt file_1.txt
Could you point me the errors and help me to correct it? And also, I want to know how to do this job by using Awk script.
# 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开发者_JS百科 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
$ 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
精彩评论