remove an entry from your PATH variable

Latest response

Hi guys,

if my PATH=/usr/local:/usr/sbin:/usr/bin:/home/admin

and I want to remove /usr/sbin from the PATH, how do that? and how do I make the change permanent?

I appreciate your assistance.

Thanks

Arrey

Responses

This may not be the cleanest way possible, but I believe this should work just fine...

[jradtke@cypher ~]$ PATH=/usr/local:/usr/sbin:/usr/bin:/home/admin
[jradtke@cypher ~]$ echo $PATH
/usr/local:/usr/sbin:/usr/bin:/home/admin
[jradtke@cypher ~]$ PATH=(`echo $PATH | /bin/sed 's/\/usr\/sbin://g'`)
[jradtke@cypher ~]$ echo $PATH
/usr/local:/usr/bin:/home/admin

Here is the way I first worked through.. but it was uglier..

[jradtke@cypher ~]$ PATH=/usr/local:/usr/sbin:/usr/bin:/home/admin
[jradtke@cypher ~]$ echo $PATH
/usr/local:/usr/sbin:/usr/bin:/home/admin
[jradtke@cypher ~]$ newPATH=`echo $PATH | /bin/sed 's/\/usr\/sbin://g'`
[jradtke@cypher ~]$  PATH=$newPATH
[jradtke@cypher ~]$ echo $PATH
/usr/local:/usr/bin:/home/admin
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.