[Techtalk] problem with changing directory in a script

Miriam English mim at miriam-english.org
Mon Sep 14 09:03:50 UTC 2015


Hi all,

In a terminal I can assign "~/folder" to a variable:
test="~/folder"
but when I try to cd to it:
cd $test
it gives the error:
bash: cd: ~/folder: No such file or directory
yet it definitely exists and it even names it correctly in the error 
message.

I can use exactly the same process with a directory that doesn't have a 
tilde in the name and it works fine.

Does anybody know why the tilde appears to trip this up?
And if there is a workaround?


-- 
If you don't have any failures then you're not trying hard enough.
  - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
-----
Website: http://miriam-english.org
Blogs:   http://miriam-e.dreamwidth.org
          http://miriam-e.livejournal.com




More information about the Techtalk mailing list