doing operations with bash script
Dear all, I am trying to do some operation within a bash script but I am running into problems very early. Say I want to do the following: - omegaNew=`echo "$omegaNew+$torque*$dt/$momentOfInertia*180/$pi" | bc -l` --- I got these outputs: - torque= -0.0665625 dt= 0.0012 omegaNew= -.00026392835805117909 torque= 0.48041 dt= 0.000101208 omegaNew= -.00010327107397767696 (standard_in) 1: syntax error torque= 1.14457 dt= 2.39891e-05 omegaNew= --- Does this mean that the operation is not carried if the torque is not in the form 0.**? If so, why is that? Another unrelated question: I got this output message, -- sed: -e expression #1, char 1: unknown command: `C' - even the command did what it was supposed to do (i.e., inserting a line) whould one know how to get rid of this thing? Best regards to all. -- View this message in context: http://old.nabble.com/doing-operations-with-bash-script-tp33447614p33447614.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: doing operations with bash script
I found where the error is coming from. it is rather form dt that is written in exponential format and not from torque. Now I have to convert it in decimal format. alphabah wrote: > > Dear all, > > I am trying to do some operation within a bash script but I am running > into problems very early. > > Say I want to do the following: > - > omegaNew=`echo "$omegaNew+$torque*$dt/$momentOfInertia*180/$pi" | bc -l` > --- > I got these outputs: > - > torque= -0.0665625 dt= 0.0012 omegaNew= -.00026392835805117909 > torque= 0.48041 dt= 0.000101208 omegaNew= -.00010327107397767696 > (standard_in) 1: syntax error > torque= 1.14457 dt= 2.39891e-05 omegaNew= > --- > Does this mean that the operation is not carried if the torque is not in > the form 0.**? > If so, why is that? > > Another unrelated question: > I got this output message, > -- > sed: -e expression #1, char 1: unknown command: `C' > - > even the command did what it was supposed to do (i.e., inserting a line) > whould one know how to get rid of this thing? > > Best regards to all. > > > > -- View this message in context: http://old.nabble.com/doing-operations-with-bash-script-tp33447614p33448226.html Sent from the Gnu - Bash mailing list archive at Nabble.com.