Embarrassingly simple bash scripting help Embarrassingly simple bash scripting help unix unix

Embarrassingly simple bash scripting help


The test command is definitely wrong.

Just remember "[" in bash is a command, not a syntax. It expects the string "]" as the last argument. This is why spaces are required before and after them. (Semicolon is OK, because it is a part of the syntax)

Also, as Kerrek pointed out, the comparation operator is -lt not lt.


The test functions need a hyphen in front of the option:

if [ $i -lt 10 ] ; then    # ....fi

Note that [ is just an ordinary command, usually in /usr/bin/[, and it has to be treated as such.