I wrote this code in bash scripting and can't figure out what the error is. The terminal say: 15: [:Illegal number: 0+1
This is the code: #!/bin/bash min=999 max=0 n=0 num=0 promedio=0 i=0
echo "Ingrese n"
read n
while [$i -le $n] ---> LINE 15 IN THE ACTUAL SCRIPT, HERE IS THE ERROR I CANT FIND
do
echo "Ingrese numero"
read num
if [$num -lt $min]
then
min=$num
fi
if [$num -gt $max]
then
max=$num
fi
promedio=$promedio+$num
i=$i+1
done
media=$promedio/$n
echo "Mayor: $max"
echo "Menor: $min"
echo "Promedio: $media"
I tried many things but as I'm not an expert and I couldn't find any solution on the internet I am posting this question.
[$iand[ "$i"are two different things.i=$i+1should bei=$(( i + 1 )); your current code stores1+1when what you want to store is2. The same is true for all the other places you want to do arithmetic operations.