bash: .bashrc: 第 148 行:語法錯誤:意外的檔案結尾

bash: .bashrc: 第 148 行:語法錯誤:意外的檔案結尾

我必須在 中設定路徑.bashrc。我使用打開它vi .bashrc並錯誤地省略了最後一行(包含帶有 的內容fi),然後添加了路徑。我使用保存它:wq。這樣做時source .bashrc顯示:

bash: .bashrc: line 148: syntax error: unexpected end of file.

這些是最後幾行~/.bashrc

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
PATH=$PATH:/home/rbh/PROGRAMS.330/bin 
export PATH

答案1

你的.bashrc應該看起來像這樣

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

PATH=$PATH:/home/rbh/PROGRAMS.330/bin export PATH

您最後刪除fi了關閉 if 區塊條件的內容

相關內容