Linux provides several methods for calculating expressions using the command line.
Using bc
— basic calculator for command line
bc
is a native Linux tool (originated on Unix systems in 1975) that stands for “basic calculator”. To use it, simply type bc
followed by an expression. To quit, type quit
.


Additionally, variables, arrays, algebraic expressions, etc. can be used. Refer to the bc
manual for more information.
Using expr
The expr
command evaluates basic expressions.


Keep in mind, it should be used for basic calculations. If something more advanced is required (like parenthesis), bc
or arithmetic expansion may be more suitable.
Using arithmetic expansion
Arithmetic expansion evaluates an expression and substitutes the result. In combination with echo
, it can be used as a calculator.


Using qalc
Qalc is a multipurpose crossplatform desktop calculator. It provides versatility and supports many everyday needs: currency conversion, percent calculation, etc.
Install it on Ubuntu via apt
:


Example usage:

