I am having issues getting cd
to change directory given the output of a command.
For example, the following does not work:
# should be equivalent to "cd ~"
cd $(echo "~")
# should be equivalent to "cd ~/go"
cd $(echo "~/go")
Both returning an error such as
cd: no such file or directory: ~
cd: no such file or directory: ~/go
However, I am able to specify absolute paths, such as
cd $(echo "/Users/olly")
which will successfully change directory to that location. What's more, if I omit the quotes it will work.
cd $(echo ~)
At the moment, I have a program, jump-config
, which will print the string of a path to the terminal.
jump-config
// prints ~/go/src/gitlab.com/ollybritton/jump/jump-config
I am attempting to do
cd $(jump-config)
but I am getting the error
cd: no such file or directory: ~/go/src/gitlab.com/ollybritton/jump/jump-config
I would be happy to do cd $JUMP_CONFIG
, however, the program's output is not fixed and I need cd $(jump-config)
to change.
I appreciate any explanation of the problem or help in advance.