On Sun, Apr 11, 2010 at 02:56:38PM -0400, Rue U wrote:
> The "cd" command/program doesnt work with paths stored in a variable.

It does if you quote properly.

> If the variable contains the backslash.

It should not.  It should contain ONLY the actual path you want.

> var=/media/New\ Folder\ Here/
> 
> cd $var
> bash: cd: /tmp/New: No such file or directory

var=/media/New\ Folder\ Here/
cd "$var"

Or:

var="/media/New Folder Here/"
cd "$var"

Note that in your example, the backslashes are NOT contained in the
variable itself.  They are only part of the bash command which is used
to set the contents of the variable.  The variable itself contains only
the spaces which the backslashes are protecting.

The quoted-string-with-spaces variant does precisely the same thing.


Reply via email to