Using the Windows command prompt, can I echo %path% and get the resulting paths on separate rows?
Something like this, but for Windows:
echo $PATH | tr ':' '\n'
Can I do this with vanilla cmd or do I need PowerShell or JavaScript scripting?
Example echo %path% output:
C:开发者_如何学Go\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;
Desired output:
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;
Try:
($env:Path).Replace(';',"`n")
or
$env:path.split(";")
Fewer keystrokes using either the split operator or method
$env:Path -split ';'
$env:Path.split(';')
This works for me (in a cmd window):
powershell -Command ($env:Path).split(';')
精彩评论