function read_num(){
echo "Enter a lower limit"
read lower_limit
echo "Enter a upper limit"
read upper_limit
while [ [ $lower_limit -lt 1 ] || [ $lower_limit -gt $upper_limit ] ]
do
echo "Please enter again."
read_num
done
}
read_num
when I enter the two numbers lower and upper limit it gives the following output.
check.sh: line 6: [: too many arguments
And line number 6 is while loop
while [ [ $lower_limit -lt 1 ] || [ $lower_limit -gt $upper_limit ] ]
[ ]expressions don't nest, and you can't use||inside a[ ]test expression (but you can between them). This is a near-duplicate of this question (which has few other options for how to do the test).[is a command. You are trying to invoke the[command with arguments[,$lower_limit,-lt,1, and]. That's too many arguments. These kinds of error are easily avoided if you usetestinstead of[. It is less likely to be confused as a part of the grammar.read uper_limit- should beupper_limit- otherwise you'll get into the infinite recursive call.