What is the `tr` command in Windows?

HattrickNZ picture HattrickNZ · Mar 27, 2015 · Viewed 17.8k times · Source

What is the Windows equivalent of the tr command in Linux?

For example, tr can replace all colons with a newline character. Can this be done in Windows?

$ echo $PATH | tr ':' '\n'
/usr/local/bin
/usr/bin

Answer

Soheil Hashemi picture Soheil Hashemi · Mar 27, 2015


in powershell we have split
see this example

$a=( echo $env:Path | Out-String )
$a -split ";"

before :

%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System
32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Prog
ram Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Micros
oft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\010 Editor;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web P
ages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft\Web Platform
 Installer\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools\Win
NT;C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files (x86)\Microsoft Visual Studio\Com
mon\Tools;C:\Program Files (x86)\Microsoft Visual Studio\VC98\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Com
mon Files\Intel\WirelessCommon\

After:

> %SystemRoot%\system32\WindowsPowerShell\v1.0\ C:\Windows\system32
> C:\Windows C:\Windows\System32\Wbem
> C:\Windows\System32\WindowsPowerShell\v1.0\ C:\Program
> Files\Intel\WiFi\bin\ C:\Program Files\Common
> Files\Intel\WirelessCommon\ C:\Program Files (x86)\ATI
> Technologies\ATI.ACE\Core-Static C:\Program Files
> (x86)\QuickTime\QTSystem\ C:\Program Files\Microsoft SQL
> Server\110\Tools\Binn\ C:\Program Files (x86)\010 Editor C:\Program
> Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\ C:\Program Files
> (x86)\Windows Kits\8.0\Windows Performance Toolkit\ C:\Program
> Files\Microsoft\Web Platform Installer\
> C:\Windows\System32\WindowsPowerShell\v1.0\ C:\Program Files
> (x86)\Microsoft Visual Studio\Common\Tools\WinNT C:\Program Files
> (x86)\Microsoft Visual Studio\Common\MSDev98\Bin C:\Program Files
> (x86)\Microsoft Visual Studio\Common\Tools C:\Program Files
> (x86)\Microsoft Visual Studio\VC98\bin C:\Program
> Files\Intel\WiFi\bin\ C:\Program Files\Common
> Files\Intel\WirelessCommon\