
Newb Help with a Basic Bash Script...
I meant to mention the reason for this in my post, but I think I
forgot to. So, to the OP: You need spaces because `if' and `[' must
be distinct tokens, and sh delimits tokens using only spaces. The
reason they're different tokens is that `[' is basically a program (it
actually is a program, but usually you're using a shell builtin
instead) that performs the enclosed tests. All `if' does is check the
return code of its argument (`[ ... ]') and figure out where to
branch.
This lets you do things like:
if grep -q thing file; then
echo "matched (grep returned success)"
else
echo "no match (grep returned $?)"
fi
And strange but useful things like:
[ -e filename ] || exit 0
(...which is more commonly written `test -e filename'.)
--
Eric McCoy (reverse "ten.xoc@mpe", mail to "ctr2sprt" is filtered)
"Last I checked, it wasn't the power cord for the Clue Generator that
was sticking up your ass." - John Novak, rasfwrj