Real Calculator
In this challenge, you are required to create an arithmetic calculator using command-line arguments in a Bash script. The calculator should be able to perform basic arithmetic operations based on user input.
Tasks
You need to complete the following task:
- Create a Bash script that accepts two numbers and an operator as command-line arguments and performs the specified arithmetic operation.
Requirements
You must meet the following requirements:
- The script should be named
arithematic.sh
.
- The script should be located in the
~/project
directory.
- Use
expr
or bc
commands to perform arithmetic operations.
Example
labex:project/ $ bash arithematic.sh 1 + 5
[OUTPUT] Arithematic operation performed is " +" [OUTPUT]
[OUTPUT] Therefore 1+5=6 [OUTPUT]
labex:project/ $ bash arithematic.sh 12 x 2
[OUTPUT] Arithematic operation performed is " x" [OUTPUT]
[OUTPUT] Therefore 12x2=24 [OUTPUT]