0
#!/bin/bash
a=0
while ["$a" -lt 10]
do
a=`expr "$a" + 1`
echo $a
done

This is the error:

a.sh: 3: a.sh: [0: not found
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
Monil Jain
  • 11
  • 2
  • http://www.shellcheck.net/ is very handy for such typos – Sundeep Nov 04 '16 at 13:52
  • 2
    Possible duplicate of [How do I compare two string variables in an 'if' statement in Bash?](http://stackoverflow.com/questions/4277665/how-do-i-compare-two-string-variables-in-an-if-statement-in-bash), or [Why should there be a space after '\[' and before '\]' in a Bash script?](http://stackoverflow.com/questions/9581064/why-should-there-be-a-space-after-and-before-in-a-bash-script) – Benjamin W. Nov 04 '16 at 13:58

1 Answers1

0

you need to keep spaces around your brackets:

while [ "$a" -lt 10 ]

since bash interpretes strings; it uses spaces to separate words. When you write ["$a"; then bash reads: [0 (after $a is replaced with 0)

Chris Maes
  • 35,025
  • 12
  • 111
  • 136