I've two files file1 & file2 and i want to delete unmatched rows based on first column i.e. ID
File1
ID,NAME,ADDRESS
11,PP,LONDON
12,SS,BERLIN
13,QQ,FRANCE
14,LL,JAPAN
File2
ID,NAME,ADDRESS
11,PP,LONDON
12,SS,BERLIN
13,QQ,FRANCE
16,WW,DUBAI
I want to delete lines
From File1
14,LL,JAPAN
From File2
16,WW,DUBAI
Using DIFF command i am able to file but i want to delete these lines.
Also Using AWK i am able to redirect these lines to another file using below command.
awk 'FNR==NR{a[$1];next};!($1 in a)' File1 File2 > File3
But don't know how to delete.
Can we do this ?
Using sed -id 's/AWK OUTPUT/g' File1
Thanks