I have a text file contains columns of data like this:
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10
50.000 7.920 0.509 11.2 2.60 192.7 25.71 0.3490 188.6 17.81
50.170 7.920 0.609 12.2 2.72 211.7 26.17 0.3326 213.8 18.19
50.330 7.920 0.712 14.1 2.92 218.9 28.17 0.3228 215.1 21.73
...
I want to create another delimited text file (a using bash script) derived from the first one which its columns have values as these:
col1 col2 col3 col3*[-sin(col6)] col3*[-cos(col6)]
...
sin
is Sine function and cos
is Cosine function in mathematics. How should I do that?
Thanks in advance.
My longer version using bc:
awk '{printf "%f * -s (%f);\n", $3, $6}' < input.txt | bc -l > col4.txt
awk '{printf "%f * -c (%f);\n", $3, $6}' < input.txt | bc -l > col5.txt
awk '{print $1, $2, $3}' < input.txt | paste -d " " - col4.txt col5.txt
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments