PDA

View Full Version : line 4: [ too many arguments



sathvik1
June 16th, 2019, 09:01 AM
Hi,
Below is my program which is giving me an error "line 4: [ too many arguments "
Can you please help me with this?


a=0

while [ $a =lt 10 ]
do
echo $a
a='expr $a + 1'
done

again?
June 16th, 2019, 12:00 PM
a=0

while [ "$a" -le "10" ]
do
echo $a
a=$(( $a + 1 ))
sleep 0.5
done
I put in half a second sleep command so you can see it looping.
http://tldp.org/LDP/abs/html/comparison-ops.html

sathvik1
June 16th, 2019, 01:10 PM
Thanks it worked. Link was helpful.