Show PATH in a human-readable way
You can use tr
.
$ tr ':' '\n' <<< "$PATH"
/Users/arturo/.rvm/gems/ruby-1.9.3-p392/bin
/Users/arturo/.rvm/gems/ruby-1.9.3-p392@global/bin
/Users/arturo/.rvm/rubies/ruby-1.9.3-p392/bin
...
You can also do this in some shells (tested in bash and zsh):
echo -e ${PATH//:/\\n}
In zsh, you can use the $path
variable to see your path with spaces instead of colons.
$ echo $path
/Users/arturo/.rvm/gems/ruby-1.9.3-p392/bin /Users/arturo/.rvm/gems/ruby-1.9.3-p392@global/bin /Users/arturo/.rvm/rubies/ruby-1.9.3-p392/bin /Users/arturo/.rvm/bin
Which can be combined with printf
or print
.
$ printf "%s\n" $path
/Users/arturo/.rvm/gems/ruby-1.9.3-p392/bin
/Users/arturo/.rvm/gems/ruby-1.9.3-p392@global/bin
/Users/arturo/.rvm/rubies/ruby-1.9.3-p392/bin
...
$ print -l $path
/Users/arturo/.rvm/gems/ruby-1.9.3-p392/bin
/Users/arturo/.rvm/gems/ruby-1.9.3-p392@global/bin
/Users/arturo/.rvm/rubies/ruby-1.9.3-p392/bin
...
The <<<
operators are called herestrings. Herestrings pass the word to their right to the standard input of the command on their left.
$ cat <<< 'Hello there'
Hello there
If your shell doesn't support them, use echo
and a pipe.
$ echo 'Hello there' | cat
Hello there
Here's a quick way with bash
OLDIFS=$IFS IFS=: arr=($PATH) IFS=$OLDIFS
printf "%s\n" "${arr[@]}"
Expanding on Smith John's solution, this makes for a nice alias in your .bash_profile
:
alias MyPath='echo -e ${PATH//:/\\n}'