0

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
m9m9m
  • 1,393
  • 1
  • 18
  • 32

1 Answers1

2

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.

chepner
  • 446,329
  • 63
  • 468
  • 610