Reescrevemos o script de shell para você:
echo "program to find all the prime numbers from 3 to given number"
echo "enter the last number"
read number
n=$number
i=2
m=2
is_prime=0
while [ "$m" -lt "$n" ]
do
while [ "$i" -le "$m" ]
do
m=$(expr $n % $i)
i=$(expr $i + 1)
if [ "$m" -eq 0 ]
then
echo "$n is not a prime number"
exit
else
is_prime=1
fi
done
m=$(expr "$m" + 1)
done
if [ "$is_prime" -eq 1 ]; then
echo "$n is a prime number"
fi
exit
Refere-se ao seguinte: