Developer's Diary
Software development, with Terry Ebdon
|
You can examine the windows path, from the command line, using the path
command or by examining the path variable, via set path
. Both methods display the path as a single, very long, line with path elements separated by semicolons. This is rarely how I'd like to view it. It would be more useful to see each item on its own line. It's possible to see this in a GUI, e.g. via Windows+Pause / Advanced System Settings / Environment variables. But that's really not what I want.
Groovy can be used to split the line, like so:
Note the use of ‘-'PATH=’'`, to discard the prefix that would otherwise appear on the first line.
On this machine the above command displays this:
E:\test>path | groovy -n -e "line.split(';').each {println it-'PATH='}" C:\Perl64\site\bin C:\Perl64\bin C:\WINDOWS\system32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\WINDOWS\System32\WindowsPowerShell\v1.0\ C:\Program Files\Java\jdk1.8.0_92\jre\bin C:\portable\groovy-2.4.7\bin C:\Program Files (x86)\Skype\Phone\ c:\texlive\bin\win32 E:\Program Files (x86)\Graphviz2.38\bin\ C:\Program Files\TortoiseHg\ C:\Users\Terry\AppData\Local\Microsoft\WindowsApps C:\Users\Terry\AppData\Local\atom\bin C:\Users\Terry\AppData\Local\Microsoft\WindowsApps e:\cygwin64\bin E:\test>
That's much more useful. e.g. I can instantly spot that Skype's on the path, and wonder why. It's not a simple command to type though. I've now pasted it into a .cmd file, and placed it on the path:
Note the @ prefix. This prevents the line from being echoed to the screen. It's the equivalent of echo off
, but only acts on the current line.
Find me coding on GitHub, networking on LinkedIn, answering questions on Stack Exchange and hanging out on twitter.