How to list PATH environment variable values vertically or elegantly?

echo $PATH gives me a long one-liner list of values which is hard for me to read and make sense of:

/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/cpanel/composer/bin:/opt/lua/bin:/opt/puppetlabs/bin:/home/USERNAME/bin

Is there a better way, a more vertical way to get a well-sorted, maybe even numbered list of these values?

one possible way ...

echo $PATH
/home/munke/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

 echo $PATH | tr ':' '\n'
/home/mhunke/.local/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
1 Like
echo -e "${PATH//:/'\n'}"
1 Like

The '\n' works in a recent bash, but is on thin ice (I think).
More clear is \\n that the shell substitutes to \n, then the echo -e substitutes the many \n to newlines.

echo -e "${PATH//:/\\n}"

Also clear is $'\n' that bash substitutes to a newline.

echo "${PATH//:/$'\n'}"

Or put a real newline:

echo "${PATH//:/
}"

Might not look nice if the echo command were indented.

Last but not least,
echo -e substitutes some special characters in $PATH; the pure echo is more robust.