January 6th, 2014, 02:47 PM
Simple question about BASH variables
I am attempting to use a variable in a cd command and it is producing an error that I do not understand.
To test the problem I created this simple script which I called 'test'.
The script produces the following output:
echo 'with variable'
echo 'direct call'
As can be seen, the direct version of the cd command works but the version using the variable [ $BD18Root ] does not.
./test: line 3: cd: ~/NetBeansProjects/BOARD18: No such file or directory
What am I doing wrong?
January 6th, 2014, 06:01 PM
~ is interpreted by the shell but not when you put it in quotes. With the quotes you've told it to literally go to the "~/NetBeansProjects/BOARD18" directory. It doesn't get interpreted with the cd either because you told it to use the BD18Root variable as the argument.
Remove the quotes.
January 6th, 2014, 07:07 PM
Works fine without the quotes. Thanks!!