Bash

.bash_profile 別名轉義引號?

  • August 25, 2018

我想為我的 .bash_profile 添加一個簡單的別名,但無論我使用哪種引用方法,我都會收到錯誤消息。

我想將此添加到我的個人資料alias htdoc=cd /Applications/MAMP/htdocs/中。儘管我使用了哪些引號,但我得到了這個錯誤

-bash: alias: /Applications/MAMP/htdocs/‘: not found

-bash: alias: ‘/Applications/MAMP/htdocs/‘“: not found

-bash: alias: ‘/Applications/MAMP/htdocs/‘: not found

-bash: alias: “/Applications/MAMP/htdocs/“: not found

-bash: alias: “/Applications/MAMP/htdocs/“‘: not found

您使用的引號字元是特殊的 Unicode 引號,( U+201C,左雙引號) 和( U+2018 - 左單引號) - 可能是複制和粘貼的結果?

您應該改用純 ASCII 引號字元之一:

alias htdoc='cd /Applications/MAMP/htdocs/'

或者:

alias htdoc="cd /Applications/MAMP/htdocs/"

引用自:https://unix.stackexchange.com/questions/109782