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,655
  • 3
  • 21
  • 41

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
  • 497,756
  • 71
  • 530
  • 681