I want to subtract the second line with the first line. The file is like this
tmptxt
A B 1 2 3 4
C D 9 8 7 6
The desired output is
8 6 4 2
How to do this in awk?
I managed to output for a single column only:
awk '{$temp=$3-prev3; prev3=$3}{print $temp}'
Best Answer
A solution with awk
gives a result of
Since awk interpret strings without valid numbers as 0 during arithmetic operations, in case you want to remove the results in which the source field contains non-numeric values, you can do this by adding an additional condition.
gives a result of