using awk to compare two files

Hi,

I have two tab separated files;

file1:

S.No ddi fi cu o/l t+ t-
1 0.5 0.6 o 0.1 0.2
2 0.2 0.3 l 0.3 0.4
3 0.5 0.8 l 0.1 0.6

file2:

S.No ddi fi cu o/l t+ t-
1 0.8 0.9 o 0.5 0.6
2 0.5 0.2 o 0 0
3 0.2 0.3 l 0 0
4 0.5 0.6 l 0 0
5 0.25 0.32 o 0.3 0.6

Desired output:
S.No ddi fi cu o/l t+ t-
1 0.8 0.9 o 0.5 0.6
2 0.5 0.6 o 0.1 0.2
3 0.2 0.3 l 0.3 0.4
4 0.5 0.8 l 0.1 0.6
5 0.25 0.32 o 0.3 0.6

That is the first file's second column(Tab as feild separator) needs to be compared with all second file's second column, if match found print the first file's line, if match not found print second file's line.

Thanks in Advance,
Vasanth

---------- Post updated at 11:07 AM ---------- Previous update was at 10:48 AM ----------

  • i answered in the original thread -