Calculate differences, combining columns on seperate files into 1 file
I have 3 files:
The first one have 3 columns (stat1.txt):
3.4 97.3 7
3.2 96.2 5
3.0 95.0 6
file 2 have also 3 columns (stat2.txt)
3.3 96.0 6
3.1 94.5 8
2.9 94.1 6
file 3 got 2 columns (num.txt):
3.2 0.5
3.3 0.7
2.9 0.4
i want to calculate the differences in value for column 2 for file number 1 and 2 like this:
97.3 - 96.0 = 1.3
96.2 - 94.5 = 1.7
95.0 - 94.1 = 0.9
and combined column 2 in file number 3 (num.txt), column 2 file no 1 (stat1.txt), column 2 file no 2 (stat2.txt), and differences in result and then print into 1 file like this:
0.5 97.3 96.0 1.3
0.7 96.2 94.5 1.7
0.4 95.0 94.1 0.9
any idea how using awk script or grep or whatever script...appreciate your help...