[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash and cd
From: |
Greg Wooledge |
Subject: |
Re: Bash and cd |
Date: |
Mon, 12 Apr 2010 10:06:53 -0400 |
User-agent: |
Mutt/1.4.2.3i |
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.