Skip to main content
2 of 4
added 174 characters in body

Counting Program Query

having a little trouble with this rather basic script. This script works on Bash in my macbook pro, but not on my Linux Mint desktop, which also uses bash.

I can't figure out what;s wrong with it, unless I'm making a rookie error or assumption.

Any help would be appreciated, thanks.

EDIT*** Here is the updated code, and I'm still getting an error from bash saying:

line 6: [: -lt: unary operator expected line 16: [: -gt: unary operator expected

#!/bin/bash
clear
counter=0

function countup {
while [ $counter -lt 500 ]
do
  ((counter++))
  echo $counter
  sleep 0.2
done
countdown
}

function countdown {
while [ $counter -gt 0 ]
do
  ((counter--))
  echo $counter
  sleep 0.2
done
countup
}

countup