$ sudo JAVA_HOME=/usr/java/default /usr/local/activemq/default/bin/activemq-a
But I've noticed that if I set a variable and then call echo to show that variable echo returns nothing.
$ FOO=bar echo $FOO
(nothing was returned)
But I can export the variable and then call echo and it works:
$ export FOO=bar ; echo $FOO
Or if I set the varaible and then call "env" to check it I see the environment variable is set:
$ LALA=FUN env |grep LALA
So why can't I set the variable and then check it with echo like in the first example above?
I got my answer on facebook from Douglas Kilpatrick who wrote: because variable substitution is done before command parsing. So when the command gets run, it's already "FOO=bar echo ''"
Solution (provided by Douglas Kilpatrick):
$ FOO=baz eval 'echo $FOO'