maniat1k
maniat1k

Reputation: 460

Spaces with bash

I'm trying to make an export of a folder with spaces... but I did'nt find out how...

:~> export PATH="/home/solo/VirtualBox\ VMs/"
:~> cd $PATH
bash: cd: /home/solo/VirtualBox\: No existe el fichero o el directorio

I thought that with a "\" I could solve but did not.

Upvotes: 2

Views: 1332

Answers (2)

Shahbaz
Shahbaz

Reputation: 47523

In bash, when you write inside " or ', you don't need to escape many of the characters.

In your case,

export PATH="/home/solo/VirtualBox VMs/"

should do.

Note that, space, and many other characters have special meaning and you escape them so bash won't get confused and use them with their special meanings. When you put stuff inside ", there is no confusion because everything is taken literally (almost) and there is no need for escaping.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798666

You've already escaped it with the quotes; there's no need for a backslash, just don't forget the quotes each time. But FFS, don't use $PATH; that env var is important.

Upvotes: 9

Related Questions