I have two files ,
$cat file_1.txt
95335df46cfdb345c0214296e0043c00,NA
a0af947a85e6895dab70eaec136cfed2,NA
$cat file_2.txt
77f673137c17b4b0405d13060e9715a3,5,X,Y
874d51610c15975c82c081aba0b096c3,5,A,M
95335df46cfdb345c0214296e0043c00,5,M,N
I'm comparing first
field from "file_1.txt" against first
field against "file_2.txt"
. If there is 'hash'
any match , get the complete matching line from "file_2.txt"
.
Matched Line : ( From file_2.txt
)
95335df46cfdb345c0214296e0043c00,5,M,N
I tried using awk
, But not getting any results.
$ awk 'NR==FNR{a[$1];next} ($1) in a' file_1.txt file_2.txt
Am i making any mistake here ? Any suggestions please ?
$ awk -F, 'NR==FNR{a[$1];next} $1 in a' file_1.txt file_2.txt
95335df46cfdb345c0214296e0043c00,5,M,N
You missed specifying that ,
is delimiter to use