LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-08-2011, 07:00 PM   #1
ztdep
Member
 
Registered: Jul 2005
Posts: 196

Rep: Reputation: 31
how to remove a path from the default $PATH


Dear friends:
My system $PATH is :
/usr/lib64/mpi/gcc/openmpi/bin:/home/ztdep/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit

i want to delete the first "/usr/lib64/mpi/gcc/openmpi/bin" , since i need to install the mpich2.2 by myself
Could you please give me some help.
 
Old 12-08-2011, 07:47 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Depends on how it got added ...
  1. System global
    • /etc/profile
    • /etc/profile.d/*
  2. User specific
    • ~/.bashrc
    • ~/.bash_login
    • ~/.bash_profile
    • ~/.profile

Check the files/directories ... if it under /etc/profile.d/ just grep for the path.


Cheers,
Tink
 
Old 12-08-2011, 11:59 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
As Tinkster says, if you want to change it permanently, you need to track down the line where it's being set, and modify that.

But to remove an entry from the current PATH "on the fly", you can use a simple parameter substitution.

Code:
del='/usr/lib64/mpi/gcc/openmpi/bin:'
export PATH="${PATH//$del}"
Just take care to note which side the colon needs to be on, if the pattern is at the beginning or end of the path.

I use this technique in a small function that toggles the availability of a directory of scripts I only need to use occasionally (I don't like to have them generally available, as they clutter up some common tab completions).

Code:
myscripts (){
    local pathadd="$HOME/myscripts"

    if [[ $PATH =~ $pathadd ]]; then
        export PATH="${PATH//:$pathadd}"
        echo "myscripts off"
    else
        export PATH="$PATH:$pathadd"
        echo "myscripts on"
    fi
}
 
Old 12-10-2011, 11:52 PM   #4
ztdep
Member
 
Registered: Jul 2005
Posts: 196

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by Tinkster View Post
Depends on how it got added ...
  1. System global
    • /etc/profile
    • /etc/profile.d/*
  2. User specific
    • ~/.bashrc
    • ~/.bash_login
    • ~/.bash_profile
    • ~/.profile

Check the files/directories ... if it under /etc/profile.d/ just grep for the path.


Cheers,
Tink
Dear tink:
Thank you very much for your feedback. The path is the default PATH after i installed the opensuse 12.1.
I have use the grep in the "/etc/profile /etc/profile.d/* and /.bashrc /.profile , it can not find anything.
Could you please give me futher instruction.
Regards
 
Old 12-11-2011, 12:02 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Code:
grep PATH /etc/profile /etc/profile.d/* ~/.bashrc ~/.bash_login ~/.bash_profile ~/.profile
 
Old 12-11-2011, 12:03 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by ztdep View Post
Dear tink:
Thank you very much for your feedback. The path is the default PATH after i installed the opensuse 12.1.
I have use the grep in the "/etc/profile /etc/profile.d/* and /.bashrc /.profile , it can not find anything.
Could you please give me futher instruction.
Regards
How odd ... You could try the following

Code:
find /etc -type f -exec grep -H /usr/lib64/mpi/gcc/openmpi/bin {} \;

Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to get the absolute path of the running executable file and current work path ? 915086731 Programming 3 11-01-2011 09:28 AM
How to remove directory from $PATH infraredgirl Linux - Newbie 13 03-19-2011 03:22 AM
how do I remove a variable from PATH melinda_sayang Slackware 17 02-28-2009 12:55 PM
how to remove path using sed dtcs Programming 2 12-25-2006 04:29 PM
how to remove PATH variable? greg108 Linux - Newbie 2 08-22-2003 01:55 PM


All times are GMT -5. The time now is 05:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration