0

I want to remove from the path environment variable all of the enteries that contain a certain word, how can I do that?

2 Answers 2

0
export PATH=$(echo $PATH | awk -F : 'BEGIN{ORS=":"}{for (i=1;i<=NF;i++) if ($i !~ /local/) print $i}' | sed 's/.$//')

Will exclude all the $PATH entries which contain the word "local".

0
0

With zsh, where $PATH is mapped to the $path array like in csh:

path=( ${path:#*word*} )

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.