Calc

calc

Evaluate an arbitrary arithmetic expression using bc. Input must be quoted or stored in a variable to avoid shell interpretation.

Example

calc "4.2 + 2.6"         # => 6.8
calc "(4.2 + 2.6) - 3.5" # => 3.3

Arguments

  • ... (string): A quoted arithmetic expression

Exit codes

  • 0: Always

Output on stdout

  • Result of the expression