Super User is a question and answer site for computer enthusiasts and power users. 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 just upgraded to Lion and I am using bash for the first time (my previous experience is with csh and tcsh). I have encountered unexpected behavior. A simple example is:

  1. I create a file containing the following commands:

    echo PATH BEFORE is $PATH
    export PATH
    echo PATH AFTER is $PATH
  2. I open a terminal (in bash) and execute the file shown above. It echoes the expected result:

    PATH BEFORE is /usr/bin: ...
    PATH AFTER is /usr/local/fortran:/usr/bin ...
  3. I then type:

    echo $PATH

    and /usr/local/fortran is NOT part of the path. I assumed that the export command would make the PATH sticky. Can someone explain why this is not happening?

share|improve this question

You need to source the file so that the exported variables are accessible to the current shell.

source script-file
echo $PATH

… or add the export command to one of bash's configuration files — In OS X, that'd typically be .bash_profile.

share|improve this answer
"source" solves the problem. thanks – DMF May 20 '12 at 17:07
@DMF If you want it to stick for every terminal session, see my update to the answer. – slhck May 20 '12 at 17:09
This is for code that I am embedding in a GUI. I don't (and don't want to) alter things that .bash_profile. Instead, I want to execute that change in $PATH only for the present shell. So, the "source" approach solves the problem. – DMF May 20 '12 at 17:35
@DMF Alright. Make sure you accept Prince John Wesley's answer by clicking the checkmark next to it! :) – slhck May 20 '12 at 17:41


export PATH

in your .bash_profile file.

How do you execute the file containing the command ? Try sourceing it with source (man source)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .