2

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.

2 Answers 2

9

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.

Sign up to request clarification or add additional context in comments.

1 Comment

To elaborate: PATH is a colon-separated list of directories which the shell uses to determine where to look for a command if it is just a word (not an absolute or relative path). You shouldn't use it for your own purposes. If you meant to add to PATH, you probably want to say export PATH="/home/solo/VirtualBox VMs":$PATH, although that does not appear to be what you meant.
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.