$ has a special meaning in all shells.
The reason I knew you were using bash is because bash (and sh, but it's
almost never used for interactive stuff) is the only shell that uses "export"
the others have something called "setenv". Which is confusing because
bash uses printenv to show your environment, just like the other shells.
A very stripped down, probably inaccurate in some places explanation:
A shell has a precedence order for its "operators" (think mathematics and
multiplication/addition/parentheses). It turns out that when a $ is in a
bash command, it is near the top of the precedence peking order. This
means that when bash sees a $, it thinks "Oh, this means what is next
is a variable, and I should evaluate that variable before I do anything else".
Since you tried to "export" a variable that was undefined, you received an
error.
What export does is it "exports" the given keyword/variable to the
entire environment (which is actually limited to this particular instance of
the shell).
Yes, you typically call the environment variable with a $VARIABLE.
All shells use the $ as an indication of a variable, though they can use it in
different ways.
try:
tcsh
setenv BLAH /usr/src
echo $BLAH
printenv BLAH
you'll get get /usr/src returned both times. This is because printenv
expects an environment variable, and the shell interprets (expands) the
$BLAH to be a variable and finds that variable in its environment setup.
Now try printenv $BLAH
You get nothing back. Why? This is because $BLAH is expanded to
/usr/src before it's passed to printenv, and there is no environment variable
called "/usr/src", so it returns nothing.
The above turns out to be similar to bash. Let it suffice to say that there
ARE differences in the way variables are handled (among other things)
between the shells, and that there isn't necessarily a best shell. If you
want to learn about shell scripting, O'Reilly has some good books on the
various shells. Hunt around your various 'bin' directories and you'll find
many different shell scripts, read through them, try to make some of your
own, fail, try again, succeed.