It's usually helpful to give some background about what you're trying to do. Asking direct questions without any context can come across as a bit rude.
Anyway...
http://mywiki.wooledge.org/BashPitfa...22.24foo.22.5D
"
[" is a
command (a synonym for
test), and everything that follows it is an argument to that command. This means that each argument has to separated by at least one space.
You should also get in the habit of quoting variables inside them to avoid word splitting.
http://mywiki.wooledge.org/BashPitfa...22.24foo.22.5D
Edit: and in this case it's absolutely necessary. If the variable were null, then after variable substitution the unquoted test would become simply
[ -n ], and you'd be testing
nothing (or perhaps the literal string "-n", I'm not sure), rather than a null string. In any case,
test evaluates it as true.
Also consider using bash's
[[..]] extended test keyword or the
((..)) arithmetic function instead.
http://mywiki.wooledge.org/BashFAQ/031
http://mywiki.wooledge.org/ArithmeticExpression