001、
[root@pc1 test01]# ls file1 file2 [root@pc1 test01]# cat file1 a rs1 b rs2 c rs4 [root@pc1 test01]# cat file2 a 0.170721 -1.82031 0.0690841 rs1 b 0.0803412 -1.01669 0.309605 rs2 c 0.21245 0.22964 0.81843 rs3 d 0.0707158 -0.499683 0.617435 rs4 [root@pc1 test01]# awk 'NR == FNR {ay[$2]; next} $NF in ay' file1 file2 a 0.170721 -1.82031 0.0690841 rs1 b 0.0803412 -1.01669 0.309605 rs2 d 0.0707158 -0.499683 0.617435 rs4

002、
[root@pc1 test01]# ls file1 file2 [root@pc1 test01]# cat file1 a rs1 b rs2 c rs4 [root@pc1 test01]# cat file2 a 0.170721 -1.82031 0.0690841 rs1 b 0.0803412 -1.01669 0.309605 rs2 c 0.21245 0.22964 0.81843 rs3 d 0.0707158 -0.499683 0.617435 rs4 [root@pc1 test01]# awk 'NR == FNR {ay[$2]; next} !($NF in ay)' file1 file2 c 0.21245 0.22964 0.81843 rs3

。