#!/bin/sh
INTERVAL=1
COUNT=0
while [ $COUNT -le 9 ]
do
(( COUNT++ ))
sleep $INTERVAL
echo "count is $COUNT"
done
On execution.
$ sh ascript
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
count is 0
ascript: 9: COUNT++: not found
You probably want
#!/bin/bashrather than#!/bin/shat the top if you want to use bash-specific operations.Your script does work fine here on my Mac, where
shis really justbash. If yourshis a real one you might not be so lucky.