-
-
Save jpartain89/333e65e50454c50fcc83 to your computer and use it in GitHub Desktop.
Removing PATH on LINUX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create a script called remove_path_part with the contents | |
echo ":$PATH:" | sed "s@:$1:@:@g;s@^:\(.*\):\$@\1@" | |
and a script called prepend_path_part with the contents | |
if echo ":$PATH:" | grep -q ":$1:"; then echo "$PATH"; else echo "$1:$PATH"; fi | |
and a script called append_path_part with the contents | |
if echo ":$PATH:" | grep -q ":$1:"; then echo "$PATH"; else echo "$PATH:$1"; fi | |
make them all executable, and then call them like: | |
PATH=$(remove_path_part /path/to/remove) | |
PATH=$(prepend_path_part /path/to/remove) | |
PATH=$(append_path_part /path/to/remove) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment