Im trying to do cd to a path that is in variable called path. But cannot cd into it.
$repo="test"
path="~/code/forks/$repo/client"
echo $path #echoing correct working path
cd "$path"
pwd
Im trying to do cd to a path that is in variable called path. But cannot cd into it.
$repo="test"
path="~/code/forks/$repo/client"
echo $path #echoing correct working path
cd "$path"
pwd
The quotes are preventing the shell from expanding ~
to your home directory. (~
is a shell feature, not an actual directory name.)
path=~/code/forks/$repo/client
This expands ~
during the assignment, not when the parameter is expanded.