Bash script using negative to cycle through -
i'm trying run bash script includes nested loop within variable should cycle through negative exponents, viz:
for abpow in {-11..-9} abc = $((10**$abpow)) abcoeff in {1..9} sed -e 's/acoeff/'$abc'/'\
this inner 2 loops of code. when values in first bracket (for abpow) positive, code runs fine. however, when have them above, need, error communicated screen is:
./scripting_test2.bash: line 30: 10**-11: exponent less 0 (error token "1")
how make run? in advance.
ps: tried putting negative sign in front of $abpow
exponents still recorded positive.
bash not support floating point arithmetic (which necessary raising negative power). instead, should use bc
utility.
abc=$(bc -l <<< "10 ^($abpow)")
also, there should no spaces before , after =
in variable assignments
Comments
Post a Comment