Search code examples
shellsedpath

print $PATH line by line


The usual code to check the $PATH variable echo $PATH often print out some long and cumbersome line like: /anaconda2/bin:/anaconda2/condabin:/usr/local/Cellar/root/6.16.00/bin:~/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
which has bad readability. Is there any way I can print all the paths line by line instead on a single line? Like this:

/anaconda2/bin
/anaconda2/condabin
/usr/local/Cellar/root/6.16.00/bin
~/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin
/opt/X11/bin

Solution

  • tr tool

    Using tr:

    echo $PATH | tr : '\n'