First off, shell assignments do not allow a space before or after equal sign. Both your suggestions would actually try to run a command literally called HADOOP_HOME
.
The relative one isn't a good idea—relative paths are relative to the current working directory, not your home directory. So if you've cd
'd into ~/Documents
, then that would mean ~/Documents/.linuxbrew/…
. Not at all what you want.
The second one doesn't really work either, because of how quoting works. Expanding ~
is something the shell is expected to do—it generally shouldn't actually make it into an environment variable. But by quoting it, you've prevented that expansion. You need to leave the ~/
bit out of the quotes, or alternative use $HOME
(which will expand inside double-quotes. So, either of these should work (at least if $HOME
is set to your home directory, which it almost always is):
HADOOP_HOME="$HOME/.linuxbrew/Cellar/hadoop/2.7.3/libexec/etc/hadoop/"
HADOOP_HOME=~/".linuxbrew/Cellar/hadoop/2.7.3/libexec/etc/hadoop/"
Personally, I find the first one easier to read. There is a third option—you don't actually need any quoting here; there aren't any special characters in the name. So this is fine (and perfectly readable) too:
HADOOP_HOME=~/.linuxbrew/Cellar/hadoop/2.7.3/libexec/etc/hadoop/
Remember to export the variable as well (export HADOOP_HOME
).