I have commands in a bash
script getting data from a source text file and then adding the value of a variable to it and using it in an if/else condition.
Source data file (db_count.ini
) (Note: contains a space at the inside the double quotes):
db_ctdy_sr=" 7"
Script:
source db_count.ini
# Removing the whitespace on the stored data
n_db_sr=${db_ctdy_sr// /}
# Sum
c=0
b=7
echo "Value of db:"$n_db_sr
sm=$((n_db_sr + c))
echo "The value of db:"
echo "$sm"
echo $sm
if [ "$sm" = "$b" ]
then
echo "Success."
else
echo "Not."
fi
echo "Bye!"
But when I run the script it always me this
The value of db:7
") Syntax error Invalid arithmetic operator (error token is "
The value of:
Not.
Bye!
Any tips? Any suggestions?
Thanks!
db_ctdy_sr
assignment, for example:db_ctdy_sr=" 7\""
-- can you confirm the exact syntax that db_count.ini is using? – Jeff Schaller Jul 21 at 13:07$a
to$sm
– Edmhar Jul 22 at 0:22db_ctdy_sr=" 7"
– Edmhar Jul 22 at 0:24