Skip to content

Instantly share code, notes, and snippets.

@startergo
Created October 14, 2023 20:12
Show Gist options
  • Save startergo/9fee19c9dc15ff5207bfe8c22640dae5 to your computer and use it in GitHub Desktop.
Save startergo/9fee19c9dc15ff5207bfe8c22640dae5 to your computer and use it in GitHub Desktop.
How to display $PATH as one directory per line and change the $PATH variables
  • You can modify path display with any one of the following commands, which substitutes all occurrences of : with new lines \n.

  • sed:

$ sed 's/:/\n/g' <<< "$PATH"
  • tr:
$ tr ':' '\n' <<< "$PATH"
  • python:
$ python -c 'import sys;print(sys.argv[1].replace(":","\n"))' "$PATH"
  • Copy the contents of the $PATH
  • Delete tha $PATH variable:
export PATH=""
  • Set the new $PATH
export PATH="/path/you/want/to/keep"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment