Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 789155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:28:46+00:00 2026-05-14T21:28:46+00:00

I constantly need to attach new paths to the PATH environment variable in .bashrc,

  • 0

I constantly need to attach new paths to the PATH environment variable in .bashrc, like below:
export PATH=/usr/local/bin:$PATH
Then to make it take effect, I always do ‘source ~/.bashrc’ or ‘. ~/.bashrc’, while I found one shortcoming of doing so which make me uncomfortable.

If I keep doing so, the PATH will getting longer and longer with many duplicated entries, for example in the previous command, if I source it twice, the value of PATH will be
PATH=/usr/local/bin:/usr/local/bin:/usr/local/bin:$PATH(<-the original path).

Is there a more decent way to attach new path to PATH in bashrc without making it ugly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:28:46+00:00Added an answer on May 14, 2026 at 9:28 pm

    Another way is to check if OPATH isn’t set. If it is, set it to PATH. This will be your original PATH.

    if [ "$OPATH" == "" ];
    then
        OPATH=$PATH
    fi
    
    PATH=~/bin:$OPATH
    

    (Code is untested…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i have a list where i need to add new values constantly but
I need to constantly release a new executable with modifications to send to the
I am still new to Javascript. I need to attach a function to handle
I am programming a Java app in which i need to constantly check that
I need a very simple jQuery to constantly scroll a list of text items
I need about 1,000 words to be able to be accessed constantly by my
I need to constantly monitor a Twitter stream using Heroku. Basically what I want
I need to write a python script that constantly checks a remote web service
I need to constantly display large amounts of colored text in WPF or Silverlight,
I'm in desperate need to constantly find the heading angel between my device/location and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.