Question

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".

Was it helpful?

Solution

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

cd "$Apps"

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top