Skip to content

Instantly share code, notes, and snippets.

@jpartain89
Forked from firstval/path_delete
Last active February 18, 2016 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpartain89/333e65e50454c50fcc83 to your computer and use it in GitHub Desktop.
Save jpartain89/333e65e50454c50fcc83 to your computer and use it in GitHub Desktop.
Removing PATH on LINUX
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