Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to localy add a dir to the global $PATH variable. I added the following to my .bashrc.

export PATH=$PATH:$VRS/bin

But PATH seems to get concatenated to itself over & over every time I open a shell (i.e. PATH keeps growing). Any ideas?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

In your script/.bashrc, just use:

PATH=$PATH:$VRS/bin

so that the change is temporarily only for the script/shell session you're running. The export command will make the change permanent.

share|improve this answer

Indeed, each time you open a shell, your .bashrc is executed. And thus, with your current code, your PATH will grow indefinitely.

If you only need this change to path for your shell, you can just remove the export, and let in your .bashrc:

PATH=$PATH:$VRS/bin

If your need to have this change more global, move your line (and the code defining your $VRS) to file ~/.profile, but by keeping the export. This file is only executed at login, not each time your open a shell.

Or even to /etc/profile if you want this change to be for all users.

share|improve this answer
    
Nice, more options than mine. I didn't think of the user profile and global profile files :) –  ADTC Aug 1 '13 at 7:33

Your Answer

 
discard

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.