I am trying to compare the values in 2 columns of 2 separate file and add the difference onto 2nd file in the last column like below:
File 2 column 5 - File 1 column 5 --> store in column 6 of File 2
File 1:
test1 data2 34 2323 433 3.32
test2 data3 32 232 32 54.54
test3 data4 34 23 76 9.43
test4 data4 32 21 12 3.777
File 2:
test1 data2 34 2323 433 4.342
test2 data3 32 232 32 22.11
test3 data4 34 23 76 8.982
test4 data4 32 21 12 7.545
Resultant File 2:
test1 data2 34 2323 433 4.342 1.022
test2 data3 32 232 32 22.11 -32.43
test3 data4 34 23 76 8.982 -0.448
test4 data4 32 21 12 7.545 3.768
I am new to awk and tried this, but this doesn't work. Can someone help me explain what's going on?
awk '{a=$5;getline<f;$5-=a;}1' f=file1.log file2.log