Skip to main content
4 of 4
deleted 48 characters in body
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

Counting program fails in arithmetic test

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.

I'm still getting an error from bash saying:

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

with this updated code:

#!/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