I have two long files that have the repeating general structure,
File1:
AA 100
BB 10
File2:
AA 100
BB 1
I want to subtract column 2 from even lines of File2 from File1, but maintain/print the other information so it remains.
Desired output:
AA 100
BB 9
For which I have written the awk
:
awk '{a=$2;getline<f;$2-=a}!(NR % 2)' f=File1 File2
This produces:
BB 9
Which does the subtraction and prints the result fine, but I'm having trouble adding in the other data.
How can I also print the other data alongside this subtraction?