I'm noticing an error:
bash: syntax error near unexpected token `-105.5*7+50*3'
When executing the below script/expression:
expr (-105.5*7+50*3)/20 + (19^2)/7 | bc -l
Is there any other way to evaluate such mathematical/floating point operations?
EDIT #1
NOTE: echo
in place of expr
does resolve this however I've used expr
with bc
before and it has handled floats quite normally why not in this scenario is what I'd like to find out now.
expr
withecho
and put quotes around the expression.expr
withecho
, but you forgot the second part. Quote the expression.expr
is a command that can also perform (basic integer) arithmetic, but then it's pointless to pipe its output tobc -l
which also does mathematics. Choose one or the other, not both. Usingecho
sends the expression to the standard input ofbc -l
which then evaluates the expression.expr
in this scenario b/c the expressions involves floats.expr
can only deal with integer or strings.