Reggie Kapros Reggie Kapros - 2 years ago 76
Bash Question

Manipulate the output of echo $PATH


echo $PATH
I get this:


And what I would like is to get these in the following format:


What I tried to do:

for dir in `echo $PATH|cut -d ':' -f $i`
echo $dir
i=`expr $i + 1`

But it doesn't work. Could someone help me with an answer?

Answer Source

tr to the rescue:

echo "$PATH" | tr : '\n'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download