Now before you flag this as a duplicate please understand i did search for this problem and i already tried all of the solutions to no effect.

My script:


echo "Enter the number 3"
read t1
if [$t1 -eq 3]; then
    echo "it is 3"
elif [$t1 > 3]; then
    echo "it is greater than 3"

exit 0

The error i get is:

./g.sh: line 5: [3: command not found
./g.sh: line 7: [3: command not found

1 Answer 1


spaces needed if [ $t1 -eq 3 ]

  • you gotta be kidding me... Bash is one picky SOB. Commented Jan 18, 2014 at 3:11
  • 5
    @SkiloSkilo it's not bash - [ is its own executable. It lives in /bin on my Mac, may be elsewhere in Linux. Program names always need spaces around them.
    – MattDMo
    Commented Jan 18, 2014 at 4:08
  • In this case [ is fine, however if your variable isn't in quotes or you want pattern matching, then use [[ ibm.com/developerworks/opensource/library/l-bash-test/…
    – spuder
    Commented Jan 18, 2014 at 5:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .