开发者

Echo %path% on separate lines

开发者 https://www.devze.com 2023-02-13 03:53 出处:网络
Using the Windows command prompt, can I echo %path% and get the resulting paths on separate rows? Something like this, but for Windows:

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(';')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号