Search code examples
bashcalc

CALC "Variable" is undefined


I am trying to do:

FIELD1b=0.37920; FIELD1a=0.28069; calc '(FIELD1b-FIELD1a)**2'

But, what I get is:

"FIELD1b" is undefined

Error in commands

Solution

  • calc doesn't seem to understand shell/environment variables. You can instead pipe your expression to calc, like:

    FIELD1b=0.37920; FIELD1a=0.28069; echo "($FIELD1b-$FIELD1a)**2"  | calc -p