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 js scripting?
Example echo %path% 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\;
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\;
Just use path=${p%/*} and file=${p##*/} . Or use basename and dirname .
To print the entire path, use echo %path% . This will print all directories on a single line separated with semicolons ( ; ) To search / replace a string in a variable, use %path:a=b% which will replace all a characters with b. echo. is used to print a newline.
For Bash, you simply need to add the line from above, export PATH=$PATH:/place/with/the/file, to the appropriate file that will be read when your shell launches. There are a few different places where you could conceivably set the variable name: potentially in a file called ~/. bash_profile, ~/. bashrc, or ~/.
echo $PATH doesn't create a variable, it prints the current contents of an already-existing variable.
Try:
($env:Path).Replace(';',"`n")
or
$env:path.split(";")
Fewer keystrokes using either the split operator or method
$env:Path -split ';' $env:Path.split(';')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With