I cannot solve a very simple problem. My data file looks like:
Crap Crap 0.123456789D+09 Crap Crap
Crap Crap 0.123456798D+09 Crap Crap
I need to use AWK to subtract the number in the third column; the SECOND row minus the FIRST row.
I tried:
cat crap.txt | awk '{ A[NR-1] = $3 } END { print A[1] - A[0] }'
to no success. Maybe the format of the number is wrong? (Can AWK read scientific notation with D
instead of E
?)
Help!
EDIT:
Just so the community knows, AWK does not understand scientific notation which uses D
instead of E
(like many Fortran outputs produce). It is necessary to replace the D
for E
and then carry on any mathematical operation.