?

Log in

No account? Create an account

Previous Entry | Next Entry

Split PATH: One per Line

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/jsaikia/impscripts/

Now to  the PATH:

$ echo $PATH | awk -F : '{print "PATH is set to\n++++++++++++++"} {for (i=1;i<=NF;i++) {print "["i"]",$i}}'
PATH is set to
++++++++++++++
[1] /usr/local/bin
[2] /usr/bin
[3] /bin
[4] /usr/bin/X11
[5] /usr/games
[6] /home/jsaikia/impscripts/

Another simple way of doing it:

$ echo $PATH | tr ':' '\n' | awk '{print "["NR"]"$0}'
[1]/usr/local/bin
[2]/usr/bin
[3]/bin
[4]/usr/bin/X11
[5]/usr/games
[6]/home/jsaikia/impscripts/


Make this a function in .bash_profile or .profile.

mypath ()
{
echo $PATH | tr ':' '\n' | awk '{print "["NR"]"$0}'
}

which will split out the elements of a PATH, one per line.

$ mypath
[1]/usr/local/bin
[2]/usr/bin
[3]/bin
[4]/usr/bin/X11
[5]/usr/games
[6]/home/jsaikia/impscripts/ 

Profile

jaduks
Jadu Kumar Saikia

Latest Month

January 2008
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  
Powered by LiveJournal.com
Designed by chasethestars