I have a two files containing numbers like below. First one contains one number on each line, the other is a table of numbers, each separated by a space. There are the same number of lines in each file.
I want to take each number in the row of the table and find the difference from the corresponding line of the first list. So each value in the row is subtracted from the value in the list at the corresponding line number using awk.
For example
5
6
7
8
9
1 2 3 4 5
5 4 3 2 1
1 2 3 4 5
1 2 3 4 5
5 4 3 2 1
Result should be
-4 -3 -2 -1 0
-1 -2 -3 -4 -5
-6 -5 -4 -3 -2
-7 -6 -5 -4 -3
-4 -5 -6 -7 -8
Actual files will be something like below
0.4117983
0.4735530
0.6167929
0.7095670
0.7897300
0.8662801
0.9425200
1.020120
1.099846
1.181320
1.263659
1.347084
1.431774
1.520824
1.610451
1.701591
1.793289
1.882924
1.969465
0.403564 0.403564 0.403564 0.403564 0.403564
0.464079 0.464079 0.464079 0.464079 0.464079
0.604454 0.604454 0.604454 0.604454 0.604454
0.695379 0.695379 0.695379 0.695379 0.695379
0.773935 0.773935 0.773935 0.773935 0.773935
0.848954 0.848954 0.848954 0.848954 0.848954
0.923670 0.923670 0.923670 0.923670 0.923670
0.999718 0.999718 0.999718 0.999718 0.999718
1.077850 1.077850 1.077850 1.077850 1.077850
1.157690 1.157690 1.157690 1.157690 1.157690
1.238390 1.238390 1.238390 1.238390 1.238390
1.320140 1.320140 1.320140 1.320140 1.320140
1.403130 1.403130 1.403130 1.403130 1.403130
1.520820 1.520820 1.520820 1.520820 1.520820
1.642660 1.642660 1.642660 1.642660 1.642660
1.735620 1.735620 1.735620 1.735620 1.735620
1.829160 1.829160 1.829160 1.829160 1.829160
1.920580 1.920580 1.920580 1.920580 1.920580
2.008860 2.008860 2.008860 2.008860 2.008860