EN
Bash - how to write simple calculator?
16 points
Using bash it is possible to write simple calcualtor in following way.
calcualtor.sh
file:
xxxxxxxxxx
1
2
3
set a b operation;
4
5
echo -e "Select operation type: + - * /";
6
read operation;
7
echo "a=";
8
read a;
9
echo "b="
10
read b;
11
12
echo "Result:" $(($a$operation$b));
Running:
xxxxxxxxxx
1
$ ./calculator.sh
2
Select operation type: + - * /
3
+
4
a=
5
3
6
b=
7
6
8
Result: 9