Discussion: variable expansion
Afficher un message
Vieux 10/11/2007, 18h18   #6
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: variable expansion

On 2007-11-10, Luntain wrote:
>
> I want to define a variable pointing to my desktop location, in bash I say
>
> desktop="\"/cygdrive/c/Dokumente und Einstellungen/Luntain/Desktop\""
>
> When I echo it looks ok, and yet when I input cd $desktop it complaints
> that there is no /cygdrive/c/Dokumente directory. wtf? I also tried
> defining desktop using '\ ', that is
>
> desktop="/cygdrive/c/Dokumente\\ und\\ Ein...
>
> I do it obviously in cygwin bash, and I don't know if it would work on
> Linux.


The quotes are not part of the path; remove them.

desktop="/cygdrive/c/Dokumente und Einstellungen/Luntain/Desktop"

When you use it, quote the variable, e.g.:

cd "$desktop"

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
 
Page generated in 0,04397 seconds with 9 queries