Calculator in terminal, some commands to use in Ubuntu

About calculator in terminal

In the next article we are going to take a look at some commands to use the calculator from the terminal from Ubuntu. Many Gnu / Linux users usually need to use the calculator from the terminal several times a day for some purpose, so it is always interesting to know some options.

Today we can find many commands available for this purpose. These calculators for the terminal will allow us perform all kinds of calculations simple, scientific or financial. We will also be able to use these commands in shell scripts for more complex math. Next we are going to see some of the most used.

Commands for using the calculator in the terminal

calculate 1
Related article:
Qalculate: A powerful free and open source calculator

Bc command

Bc stands for basic calculator. Supports arbitrary precision numbers with interactive execution of statements. It has some similarities in the syntax of the C programming language.

bc help

By default, the command bc we will find it installed on all Gnu / Linux systems. If you cannot find it installed on your Debian / Ubuntu system, you can use the following command to install bc by opening a terminal (Ctrl + Alt + T) and typing in it:

sudo apt install bc

Use the bc command

We can use the bc command to perform all kinds of calculations directly from the terminal (Ctrl + Alt + T) by typing in it:

command bc operations

If we use the -l option the standard math library is going to be defined:

command bc -l

bc -l

Calc command

Calc is a simple calculator that allows us to perform all kinds of calculations on the command line. To install it on Debian / Ubuntu systems, we can use the following command in the terminal (Ctrl + Alt + T) to install calc:

install apcalc command

sudo apt install apcalc

Use the calc command

We will be able to use the calc command to perform all kinds of calculations directly from the terminal (Ctrl + Alt + T) using the interactive mode, writing:

calc

If we prefer to use the non-interactive mode, you just have to write the command followed by the operation to be performed:

non-interactive calc command

calc 88/22

Expr command

This command will print the value of the operation that accompanies expose on standard output. It is part of coreutils, so we don't need to install it.

Use the expr command

We will use the following format for the basic calculations.

To add:

expr sum

expr 5 + 5

To subtract:

expr subtraction

expr 25 - 4

To divide:

expr division

expr 50 / 2

Gcalccmd command

Gnome-calculator is the official calculator for the GNOME desktop environment. Gcalccmd is the console version of the utility Gnome Calculator.

To install this command you just have to open a terminal (Ctrl + Alt + T) and write in it:

install gcalccmd

sudo apt install gnome-calculator

Use the gcalccmd command

In the following screenshot you can see some examples of use:

gcalccmd command

gcalccmd

Qalc command

It is an easy-to-use calculator, but it provides the power and versatility They are usually reserved for complicated math packages, as well as useful tools for everyday needs.

Features include a large library of customizable functions, unit calculations and conversions, symbolic calculations (including integrals and equations), arbitrary precision, interval arithmetic, plotting, and an easy-to-use interface (GTK + and CLI).

For Debian / Ubuntu systems, we will be able to use qalc by typing in a terminal (Ctrl + Alt + T) the following command:

install alc

sudo apt install qalc

Use the qalc command

In the following screenshot you can see some examples to get a little idea of ​​how to use this calculator:

qalc command

qalc

It can consult more about qalc on your page GitHub.

Shell commands

We will be able use shell commands like echo, awk, etc. to perform the calculation of operations. For example, to perform an option you just have to type the following in the terminal (Ctrl + Alt + T):

shell command

echo $[ 34 * (12 + 27) ]

In this case we will also be able to use variables when performing calculations:

shell command with variables

x=5
y=6
echo $[ $x + $y ]

The calculator is undoubtedly one of the most essential tools that we must have in any day-to-day system. For this reason, if you are an administrator or a user who uses the terminal daily, these commands that we have seen above may be useful.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Charlie brow said

    Charlie brow