I'm attempting to get into the directory /cygdrive/c/Users/my dir/Documents
:
$ DOCS="/cygdrive/c/Users/my\ dir/Documents"
$ echo $DOCS
/cygdrive/c/Users/my\ dir/Documents
$ cd $DOCS
-bash: cd: /cygdrive/c/Users/my\: No such file or directory
$ cd /cygdrive/c/Users/my\ dir/Documents
(success)
When I manually type it in, the backspace does its escape character thing, but not when I use parameter expansion with the variable DOCS
.
I tried other variations such as no backslash.
$ DOCS=/cygdrive/c/Users/Rahman\ dir/Documents
$ echo $DOCS
/cygdrive/c/Users/my dir/Documents
$ cd $DOCS
-bash: cd: /cygdrive/c/Users/my: No such file or directory
or
$ DOCS="/cygdrive/c/Users/my dir/Documents"
$ echo $DOCS
/cygdrive/c/Users/my dir/Documents
$ cd $DOCS
-bash: cd: /cygdrive/c/Users/my: No such file or directory
The same happens for $HOME
:
$ echo $HOME
/home/my dir
cd $HOME
doesn't work either. Quotes must be put around it.
What the heck:
$ DOCS="\"/cygdrive/c/Users/my dir/Documents\""
$ echo $DOCS
"/cygdrive/c/Users/my dir/Documents"
$ cd $DOCS
-bash: cd: "/cygdrive/c/Users/my: No such file or directory
Why not put the following in your
.cshrc
(or.bashrc
, or whatever your default shell is):First time you do this, you have to do
to update the shell with this new alias, then you can type
anytime you want to
cd
to your directory.Laziness is the mother of invention...