Say one of your data files returns you all their readings. After removing all the clutter; you obtain, with always 3 columns:
-ERROR -1.57 -2.02
-2.10 -0.57 ERROR
-4.70 ERROR -0.52
-2.20 ERROR -0.02
-2.20 -0.07 ERROR
I know ERROR is the only error message and happens for any data at random, and is, therefore, the only value that isn't a number.
THE CHALLENGE
How can I replace any invalid reading with the last successful one? I've tried
awk -F' ' ' {if (isNumber $1){ replace with previous $1}}' < log.data
But how do you reference the previous reading to begin with?
Expected output:
0 -1.57 -2.02
-2.10 -0.57 -2.02
-4.70 -0.57 -0.52
-2.20 -0.57 -0.02
-2.20 -0.07 -0.02