I'm trying to filter a file with another file. I have a file d3_tmp and m2p_tmp; They are as follows:
$ cat d3_tmp
0x000001 0x4d 2
0x1107ce 0x4e 2
0x111deb 0x6b 2
$ cat m2p_tmp
mfn=0x000001 ==> pfn=0xffffffffffffffff
mfn=0x000002 ==> pfn=0xffffffffffffffff
mfn=0x000003 ==> pfn=0xffffffffffffffff
I want to print out the lines in m2p_tmp whose second column is not equal to the first column of d3_tmp. (The files are split with \t and =)
So the desired result is:
mfn=0x000002 ==> pfn=0xffffffffffffffff
mfn=0x000003 ==> pfn=0xffffffffffffffff
However, after I use the following awk command:
awk -F '[\t=]' ' FNR==NR { print $1; a[$1]=1; next } !($2 in a){printf "%s \t 0\n", $2}' d3_tmp m2p_tmp
The result is:
0x000001
0x1107ce
0x111deb
0x000001 0
0x000002 0
0x000003 0
I'm not sure why "$2 in a" does not work. Could anyone help?
Thank you very much!
0x000002!=0x000002- William Pursell