Languages
[Edit]
EN

Bash - how to write simple calculator?

13 points
Created by:
AnnLen
9180

Using bash it is possible to write simple calcualtor in following way.

1. In brackets expression example

calcualtor.sh file:

#!/bin/bash

set a b operation;

echo -e "Select operation type: + - * /";
read operation;
echo "a=";
read a;
echo "b="
read b;

echo "Result:" $(($a$operation$b));

Running:

$ ./calculator.sh
Select operation type: + - * /
+
a=
3
b=
6
Result: 9

 

Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join