Quote:
Originally Posted by nour_
Hello everyone,
I'm new to bash scripting and i was looking at while loop examples that have the following in the condition:
while [ $x -le 5 ]
while [ $count -lt 5 ]
what does -le and -lt mean?
|
A part of the script (above the while loop) is setting "x" to some value that needs to be less than--or less than or equal to--the value 5. Or... some activity within the "body" of the while loop may be redefining "x". The script will stay in the loop until the test fails. I.e.:
Code:
#!/bin/bash
x=0
while [ $x -le 5 ]
do
echo -e "Enter a number: \c"; read x
echo $x
done
echo "We exited the loop"
(OK. Dumb example but you get the idea.)
Issue "man test" and read that page for an explanation of those two tests---the explanations are pretty clear.
HTH...