1

I am doing:

echo "scale=2; sqrt( (-9.522 - -9.522)**2 + (-17.145 - -17.145)**2 + (-2.689 - -2.689)**2 )" | bc

and I am getting:

(standard_in) 1: syntax error
(standard_in) 1: syntax error
(standard_in) 1: syntax error

I do not understand what is happening.

karel
  • 122,292
  • 133
  • 301
  • 332

1 Answers1

8

The exponentiation operator in bc is ^ not **. From man bc:

   expr ^ expr
          The result of the expression is the value of the first raised to
          the  second.  The second expression must be an integer.

Ex.

$ echo "scale=2; sqrt(2)^2" | bc
1.98
steeldriver
  • 142,475