0

I am using CentOS 6.2. This is my ~/.bash_profile content:

# .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

However, when I source it using

source .bash_profile

it returns

if: Expression Syntax.

Why?

This is my .bashrc file:

# .bashrc
# Source global definitions

if [ -f /etc/bashrc ]; then

        . /etc/bashrc

fi

# User specific aliases and functions
1
  • 2
    How does your ~/.bashrc look? Since it is sourced in .bash_profile, the error might be in there (and probably is). – Daniel Andersson Aug 9 '12 at 9:37
7

Perhaps you accidentally ran this from csh?

$ csh
lucid32:~> source if_rc
if: Expression Syntax.
lucid32:~> cat if_rc
if [ -f /etc/bashrc ]; then
    :
fi
2
  • 2
    i changed shell to bash now it's working fine. thanx – max Aug 9 '12 at 10:23
  • How I did this: I had a hunch, having once used tcsh in the grey past. if: Expression Syntax. just did not look like anything that I know from any Bourne/POSIX shell or derivative. Google and a couple of lines of code did the rest. – Henk Langeveld Aug 9 '12 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.