2

What's the proper way to do this?

$ export SUBLPKG=~/"Library/Application Support/Sublime Text 2/Packages"
$ cd $SUBLPKG
-bash: cd: /Users/$ME/Library/Application: No such file or directory


$ export SUBLPKG=~/"Library/Application\ Support/Sublime\ Text\ 2/Packages"
$echo $SUBLPKG
/Users/$ME/Library/Application\ Support/Sublime\ Text\ 2/Packages
$ cd $SUBLPKG
-bash: cd: /Users/$ME/Library/Application\: No such file or directory

1 Answer 1

7

The proper way is to quote the variable while expanding else word splitting would happen on whitespaces:

export SUBLPKG=~/"Library/Application Support/Sublime Text 2/Packages"
cd "$SUBLPKG"

You might also want to refer to Word Splitting in the manual.

Also refer to Word Splitting here.

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

1 Comment

Can anyone insert punctuation into this answer? It is unreadable.

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.