0

I used this to add to PATH:

APXS2=/usr/local/apache/bin/apxs PATH=$PATH:/usr/local/apache/bin passenger-install-apache2-module

and my PATH now looks like this:

/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:

Now I want to remove this I added. How to do this?

1

The best way might be to simply store a copy of the path before altering it.

PATH_BAK=$PATH
PATH=...
...
PATH=$PATH_BAK
| improve this answer | |
1

Just log out, login again and your PATH will be reset.

| improve this answer | |
0

If you forgot to create a backup you can use the substring removal/replace.

Substring Removal

${string#substring}

Substring Replace

${string/substring/replacement}

Please refer to this link http://www.museum.state.il.us/ismdepts/library/linuxguides/abs-guide/string-manipulation.html

| improve this answer | |
  • So what is the answer here ? Your answer does not manipulate the value of PATH - if it needed modifying anyway. – David Victor Feb 23 '11 at 23:43
0

Given /usr/local/apache/bin isn't in the '... my PATH now looks like this ...' - what do you think you added ? Assuming you're on bash or ksh - you didn't actually change the path because you didn't export it. So I doubt you need to remove anything.

E.g.

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
$ PATH=$PATH:/foo /bin/ls
aFile
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
$ # PATH did not alter

Versus:

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
$ export PATH=$PATH:/foo
$ /bin/ls
aFile
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/foo
$ #PATH modified.

So unless you exported the new PATH to the shell you're invoking the command from the PATH did not alter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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