This doesn’t explain everything — given your variable declarations, they should have a value — but since you’re using arithmetic expansion, you don’t need
$ to introduce variables; undefined variables then default to 0:
sum=$((success + etc + map))
total=$((success / sum))
Ideally you should check that
sum is non-zero before dividing, but at least you’ll get a sensible error message with this approach even if you don’t check
sum (“division by 0” rather than “syntax error: operand expected”, in bash).
The error you’re getting comes from
sum=$(($success + $etc + $map))
For some reason,
map are all undefined or empty. The shell expands the above to
sum=$(( + + ))
and then tries to expand that, which results in the syntax error you quote.
This is rather surprising though since
success=$(grep success * | grep B2B | wc -l)
should produce a value...
BTW, You may want to improve the above to:
success=$(grep success ./* | grep -c B2B)
B2B is to be matched on the content of the success lines and not on the file names:
success=$(cat ./* | grep success | grep -c B2B)
or with GNU
grep or compatible:
success=$(grep -h success ./* | grep -c B2B)