Unable to run code, error "[[Add:"
not found.
#!/bin/bash
add() {
first="${1}"
second="${2}"
result=`expr $first + $second`
echo "The sum of two numbers are $result"
return $result
}
subtract() {
first="${1}"
second="${2}"
result=`expr $first - $second`
echo "The sum of two numbers are $result"
return $result
}
echo "[0] Add"
echo "[1] Subtract"
read operation
echo "Enter Number One"
read first
echo "Enter Number Two"
read second
if [["$operation" == "Add"]]
then
add $first $second
else
subtract $first $second
fi
I am trying to run this code, the if else comparison does not work. Each time i execute the code, at line 32 an error is occurred and else is executed. I am trying to create an addition/subtraction bash sh file.
root@Kumaraswamy:~# ./maths.sh
[0] Add
[1] Subtract
Add
Enter Number One
7
Enter Number Two
3
./maths.sh: line 32: [[Add: command not found
The sum of two numbers are 4
root@Kumaraswamy:~#