Vra

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 dit nuttig?

Oplossing

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

cd "$Apps"

Ander wenke

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

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top