Spaces in bash variable path name

后端 未结 1 735
走了就别回头了
走了就别回头了 2020-12-06 22:47

What\'s the proper way to do this?

$ export SUBLPKG=~/\"Library/Application Support/Sublime Text 2/Packages\"
$ cd $SUBLPKG
-bash: cd: /Users/$ME/Library/App         


        
相关标签:
1条回答
  • 2020-12-06 23:22

    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.

    0 讨论(0)
提交回复
热议问题