Convert PATH to lines in order to grep
I want to regexp check if a path is in my PATH environment variable.There are many ways to achieve this, but this one is the one I want to show you today:
# echo $PATH | awk '{gsub(":","\n",$0); print $0;}'
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/var/cfengine/bin
I can then "grep" what I want from this.