On a Linux system, I want to modify the output of a mysql query (redirected to a file) and put the result in another file, and do it automatically.
This should be possible, in that the starting point and target file format are clear. What I would start with is this:
w1 p1 f1 r1 t1 m1
1.25 1.08 0.66 0.00 0.76 0.92
w p f r t m
1.37 1.44 1.29 0.43 1.19 1.36
w2 p2 f2 r2 t2 m2
1.25 1.58 1.25 0.33 1.20 1.39
and in each instance of this query being run, the numbers will be different (though always between 0 and 4 to two decimal places), but the labels will be the same. I want to:
a) strip out the labels, leaving just the numbers.
b) place commas, rather than tabs or spaces, between the numbers
c) add 'Pre' to the first row or numbers, 'Norm' to the second row and 'Post' to the last row
to end up with:
Pre,1.25,1.08,0.66,0.00,0.76,0.92
Norm,1.37,1.44,1.29,0.43,1.19,1.36
Post,1.25,1.58,1.25,0.33,1.20,1.39
I'm not familiar with the command line editing commands required to accomplish this task. I presume it would require three passes through the file.
Any help and pointers gratefully received.