Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a mac for some years now and as I'm currently learning ruby on rails, I felt like I should learn more about the system I'm using. I took a look at the ~/.bash_profile, it looks like this


[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$

# Setting PATH for Python 3.3
# The orginal version is saved in .bash_profile.pysave
export PATH
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/bin:$PATH

I'm completely new to this and tried to google my way though this but there are still some questions. The first one is: as there are two identical export PATH=/usr/local/bin:$PATH lines, I tried to delete the one. As a result, commands like nano and ls didn't work anymore. I reverted the change but I don't understand why it has to stated two times.

Another question is: why does it sometimes $PATH and sometimes just PATH without the $? Why does -s "$HOME/.rvm/scripts/rvm" stand in [[ ]] braces? And what does export PATH do?

Maybe someone could guide me to an easy to understand guide / tutorial / book where I could learn all this?

Update This is the output of echo $PATH


It seems like you were right with the newline. I deleted the line again and made sure that there is a blank line in the end. Now the commands are still working.

share|improve this question
Please don't combine multiple questions in a single post. The issue with PATH vs $PATH is explained here, and [[ ]] is a test operator, it basically means if. The duplicate exports should have no effect, that's weird, I recommend you focus on that one and make you question about the export. – terdon Jan 26 '14 at 15:36
Ok, sorry for the multiple questions and thanks for the answers. – Linus Jan 26 '14 at 15:43
Welcome to the bright side! Before we google, we like to read manuals, called man pages. Bash's man page (man bash) can answer all your questions. – Bananguin Jan 26 '14 at 15:56
@Bananguin in the OP's defense, man bash is 5465 lines long, not the easiest of reads. – terdon Jan 26 '14 at 16:54
up vote 2 down vote accepted

The PATH before = is a variable name and the combination tells bash to store the stuff behind the = in the variable.
The $PATH is the value of the variable PATH up until then.

The combination PATH="some_path_to_stuff:$PATH" extends the PATH variable. In bash this is a colon (:) separated list.

Regarding the double addition of /usr/local/bin, I can only guess that the second version has no newline after it (and is at the end of the file). In principle this should give you a PATH which starts with /usr/local/bin:/usr/local/bin:..... You can check that with

echo $PATH

And if there is only one time /usr/local/bin then do:

echo "" >> ~/.bash_profile

and login an try to print $PATH again.

share|improve this answer
Thanks for the additional info. I updated my question with the echo $PATH output. It looks a little weird. – Linus Jan 26 '14 at 16:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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