This code is a part of the project that i'm currently doing. I want to add 26 into the minus value elements in the array. Here is the simple code that I wrote in bash, but the output is not changing and it showing command not found. can anyone help me please:
declare -a B
B[0]=5
B[1]=-11
B[2]=-14
B[3]=25
for((i=0; i<4; i++))do
if [[ $B{[i]} < 0 ]]; then
B[$i] ="(( B[$i] + 26))"
fi
done
echo ${B[@]}
Expected Output:
5 15 12 25
But the actual output for my code:
Line ##: B[1]: command not found
Line ##: B[2]: command not found
5 -11 -14 25