I have two files x and y containing two fields emp number and emp name in each file. I want to bring out the mismatching entries and missing entries into a file. File x has the correct emp number and emp name. y has correct emp number but name is not correct or blank or correct. I used comm -13 x y > z1 and comm -13 x y >z2. The out put files now consists of unique fields in file x and file y. But i want the print output as emp number , emp name in file1 , emp name in file2 for comparing the emp names. The x and y files has more than 50000 lines.
I heard that through awk program we can do that but i couldn't achieve it. I could print either file z or file z1. but not combined output as required.
I would be thankful if you guide me at the earliest.
Thankyou
sagar
Software/Hardware used:
linux, awk programs
ASKED:
September 30, 2012 4:22 PM
UPDATED:
October 1, 2012 12:03 PM
Just very naievly assuming that the records in your two files z1 and z2 are in the same order, you can use ‘getline < “filename”‘ to read from a second file.
Again, with no testing, just displaying the content of the lines, try this:
BEGIN { num=” “ ; nam1=” “; nam2=” “ }{ num = $1 ; nam1 = $2 ; getline < “file_z2″ ; nam2 = $2 ; print num, “, “, nam1,”, “,nam2}END {}
If you need to check that the two read lines actually contain the same emp-num, it of course gets trickier….
Good Luck.
up