I have a file, say: ~/cwd
. The content of this file is a single line:
~/tmp
I want fo cd
to this (~/tmp) dir. I'm trying:
> cd `cat ~/cwd`
And got:
-bash: cd: ~/tmp: No such file or directory
Why the RELATIVE paths failed? When the content of the ~/cwd
is absolute path - it works.
Try this:
eval cd `cat ~/cwd`
The '~' needs to be expanded by the shell. The eval causes the command to be run through the shell's command processing, which includes '~' expansion.