+4 votes
455 views
How to use calculator for Linux terminal

in Linux / Unix by (551k points)
reopened | 455 views

1 Answer

+5 votes
Best answer

1. How to use the gcalccmd command in Linux
2. How to use the Qalc command on Linux
3. How to use the bc Linux command
4. How to use calc Linux command
5. How to use the Expr Linux commands

Computers have become indispensable devices for most people, as they offer important functions. Not only do we use them to browse the web and create documents, but from them we manage many of us email, access social networks or download and store different documents ..

One of the tools that have been and will continue to be present in all operating systems is the calculator thanks to which we frequently resort to calculate many goals such as making our salary, set goals, knowing how much we should cancel from some debt and more.

In the case of Linux operating systems, there are several ways on how we can use the calculator and today we will see each one in detail..


1. How to use the gcalccmd command in Linux

Step 1

This is the integrated console version of Gnome Calculator which we find in distributions with this type of environment, its use is simple since we must access the terminal and run it directly there:
 gcalccmd 
Note
If you do not have it, we can install it by executing the sudo apt install gnome-calculator command
Step 2

Once we execute this command we can execute the necessary operations of the calculator:

image

Step 3

In addition to this we can execute operations such as square root calculation with the sqrt parameter:

image

Step 4

We can detect the natural log of a number using ln:

image

Step 5

For those who are lovers of mathematics, we can use the sine, cosine or tangent variables (sin, cos, tan). To return to the terminal we will use the Ctrl + C keys.

image


2. How to use the Qalc command on Linux

Step 1

This command is the version for the terminal of the Qalculate application which allows us to perform different mathematical actions in Linux especially the conversion of currencies, for its installation we execute the following:
 sudo apt install qalc 

image

Step 2

Enter the letter S to accept the download and installation of the utility and after this process the available exchange rates should be updated, in case this does not happen, we will execute the qalc command in the terminal and then execute exrates:

image

Step 3

Then we can make use of some currency conversion:

image

Step 4

In addition to this, it will be possible to perform conversions along with regular calculations as in the following example. To return to the terminal we will use the Ctrl + C keys.

image


3. How to use the bc Linux command


The command bc (basic calculator) is one of the most used in Linux for its various functions at the level of calculations.
Step 1

For its execution it is enough to access the terminal and execute bc and there execute all the desired operations:

image

BC actions
With bc it will be possible to carry out actions such as:
  • Arithmetic operators
  • Increase or decrease operators
  • Assignment Operators
  • Comparative or relational operators
  • Logic or Boolean operators
  • Mathematical functions
  • Conditional statements
  • Iterative statements
Step 2

In bc the -l parameter allows you to set the default scale (digits after the decimal point) to 20 and similarly define the standard mathematical library:

image

Step 3

We can make use of common shells like bash, ksh, csh, in order to execute the arguments in bc directly, we can execute the following:
 bc - l <<< “3 * 7/4” 

image

Step 4

It is possible to use bc non-interactively as follows. To return to the terminal we must execute the term quit.
 echo '8/4' | bc 

image


4. How to use calc Linux command

Step 1

Calc is another of the terminal calculator utilities with which we can perform various actions, for its installation we will execute the following:
 sudo apt install apcalc 

image

Step 2

Enter the letter S to confirm the download and installation and then execute calc and proceed to perform the desired operation:

image

Step 3

Calc parameters
The use of calc is composed of some parameters such as:
  • -c: Continue reading the command lines even after an analysis error.
  • -C: Allows the execution of custom built-in functions, the default is the custom built-in function ()
  • -d: Disables printing of the opening title.
  • -D: Forces the initial value of config.
  • -e: Ignore the environment variables at the beginning of the app.
  • -f: It is used in the Shell mode of scripts.
  • -h: Displays the help of the command.

With calc we can perform additional operations such as square root, sine, cosine or tangent:

image


5. How to use the Expr Linux commands


This command can be executed directly in the terminal to carry out the desired operations without requiring additional installations.

image

Thus, the options to perform our mathematical operations on Linux are broad and functional.


by (3.5m points)
edited

Related questions

+4 votes
1 answer
asked Jun 2, 2020 in Linux / Unix by backtothefuture (551k points) | 307 views
+3 votes
1 answer
+5 votes
1 answer
+4 votes
1 answer
asked Oct 23, 2019 in Linux / Unix by backtothefuture (551k points) | 608 views
+5 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users