呃。我讨厌bash逃跑的场景。正确的方法是什么?
$ 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
我想把所有的东西都打破。
嘎啊啊啊啊啊啊啊啊啊啊啊啊。
最佳答案
正确的方法是在展开时引用变量,否则将在空白处发生分词:
export SUBLPKG=~/"Library/Application Support/Sublime Text 2/Packages"
cd "$SUBLPKG"
您可能还需要参考手册中的Word Splitting。
另请参阅分词here。