1

I am trying to create a variable in Bash to access fastly to some folders and save it to my bash_profile script file. This is how script looks like

Documents=~/Documents
Apps=~/Library/Application\ Support/iPhone\ Simulator/5.1/Applications

After running the script the $Documents variable works and $Apps doesn't. It tells:

-bash: cd: /Users/myusername/Library/Application: No such file or directory

This is the path to the folder:

/Users/myusername/Library/Application Support/iPhone Simulator/5.1/Applications

How should I escape spaces? I use Vim and I type "cd $Apps".

2 Answers 2

11

The spaces are fine; it's your command that's wrong.

cd "$Apps"
Sign up to request clarification or add additional context in comments.

Comments

0

You can also quote the string and not use the backslash character: Apps='~/Library/Application Support/iPhone Simulator/5.1/Applications' cd "$Apps"

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.