A few additional changes.
First, when comparing a string use == instead of -eq
Second, when checking for numbers between 1 and 10 using -le and -ge use an and statement instead of an or statement
if [ $NUM -ge 1 ] || [ $NUM -le 10 ]
will match
any integer number (anything else will error!)
if [ $NUM -ge 1 ] && [ $NUM -le 10 ]
will match integer numbers between 1 and 10 only (therefore more acurate)
Third, you are asking for NUM to be reentered if it is not between 1 and 10, however you are not then retesting.
I have taken the liberty of changing the code by using a case statement:
Code:
#!/bin/bash
action()
{
echo "Your number is $NUM"
FINAL=$(( $NUM * NUM ))
echo "The square of your number is $FINAL"
}
while true
do
echo "Please choose an integer number between 1 and 10"
read NUM
case $NUM in
[123456789]|[10] ) action
exit;;
[Ee][Xx][Ii][Tt] ) exit;;
* ) echo "$NUM is not an integer number between 1 and 10";;
esac
done