Команда bc
Calculator.
bc [-c] [-l] [file]
| -c | Compile only. The output is dc commands that are sent to the standard output. |
| -l | Define the math functions and initialize scale to 20, instead of the default zero. |
| file | Name of the file that contains the bc commands to be calculated this is not a necessary command. |
| L | A letter a-z |
| E | An expression: a (mathematical or logical) value, an operand that takes a value, or a combination of operands and operators that evaluates to a value. |
| S | Statement |
| /* and /* | Comment |
| sqrt ( E ) | Square root |
| length ( E ) | Number of significant decimal digits. |
| scale ( E ) | Number of digits right of decimal point. |
| quit | Exits the bc command. |
Available Operators
+ - * / % ^
(% is remainder; ^ is power)
++ -- (prefix and postfix; apply to names)
== <= >= != < > = =+ =- =* =/ =% =^
bc cal.txt = Would result in 3, see below notes.
Within the cal.txt file you could have a simple statement such as:
/* Add the value 1+2 /*
1+2
quit
When running the above command you will receive the results of the cal.txt file. Which in this case would be 3.