.bash_profile 中的错误

max*_*max 0 linux bash .bash-profile

我正在使用 CentOS 6.2。这是我的~/.bash_profile内容:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
PATH=$PATH:$HOME/bin

export PATH
Run Code Online (Sandbox Code Playgroud)

但是,当我使用它来获取它时

source .bash_profile
Run Code Online (Sandbox Code Playgroud)

它返回

if: Expression Syntax.
Run Code Online (Sandbox Code Playgroud)

为什么?

这是我的 .bashrc 文件:

# .bashrc
# Source global definitions

if [ -f /etc/bashrc ]; then

        . /etc/bashrc

fi

# User specific aliases and functions
Run Code Online (Sandbox Code Playgroud)

Hen*_*eld 7

也许你不小心运行了这个csh

$ csh
lucid32:~> source if_rc
if: Expression Syntax.
lucid32:~> cat if_rc
if [ -f /etc/bashrc ]; then
    :
fi
Run Code Online (Sandbox Code Playgroud)

  • 我将 shell 更改为 bash 现在它工作正常。谢谢 (2认同)