Print value of $PATH in readable format

January 18, 2025 ยท View on GitHub

# for bash
echo "${PATH//:/$'\n'}"
# for zsh omit the $ char
echo "${PATH//:/'\n'}"

Substitute all occurrences of ":" in $PATH with a newline "\n"

  • The $'...' way of quoting a string allows us to use special characters such as tab (\t) safely.

Resources