I have written the following script file from my book.
a=2
b=3
c=$[a+b]
echo 'The result is:' $c
After executing this program, instead of getting 5, I am getting output as:
The result is: $[a+b]
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityYou shouldn't be using []
:
Go for this (with the (())
brackets:
a=2
b=3
c=$((a+b))
echo 'The result is:' $c
returns:
The result is: 5
#!/bin/bash
at the start of your script.