Published on Linux Journal (http://www.linuxjournal.com)
Remove a path from your PATH variable
By Mitch Frazier
Created 2008-04-15 11:40

If you need to remove a path from the PATH variable before your script runs add this to the beginning of the script:

  PATH=$(echo $PATH | sed -e 's;:\?/home/user/bin;;' -e 's;/home/user/bin:\?;;')

If you need, you can re-add it at the front of the list with:

  PATH=/home/user/bin:$PATH
Or you can re-add it at the end of the list with:
  PATH=$PATH:/home/user/bin

_______________________________
Related Articles
  • Shell Functions and Path Variables [1] by Stephen Collyer
  • Distributed Compiling with distcc [2] by Jes Hall
  • Configuring Bash [3] by David Blackman
__________________________

Mitch Frazier is the System Administrator at Linux Journal.


Source URL: http://www.linuxjournal.com/content/remove-path-your-path-variable-0

Links:
[1] http://www.linuxjournal.com/article/3645
[2] http://www.linuxjournal.com/article/9814
[3] http://www.linuxjournal.com/article/4063