Awk parsing a math equation into variables -


well, i'm new awk , have input equation this:

 y = 0.02 sin(20πt-0.2πx) 

from equation,i want to:

-copy 0,02 variable

-copy sin b variable

-copy 20 20πt c variable

-copy -0.2 -0.2πx d variable

-and rid of whitespace

but don't know how in awk, can me please? in advance

you can start doing following , work way cover edge cases. please note solution extremely fragile , not work if input changes.

consider guide towards more concrete solution based on input data

$ echo 'y = 0.02 sin(20pt-0.2px)' |  awk -f'=' '{split ($2,ary,"[ (t]"); print "a="ary[2]; print "b="ary[3]; print "c="ary[4]+0; print "d="ary[5]+0}' a=0.02 b=sin c=20 d=-0.2 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -