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
The tr command is a Linux command-line utility that translates or deletes characters from standard input ( stdin ) and writes the result to standard output ( stdout ). Use tr to perform different text transformations, including case conversion, squeezing or deleting characters, and basic text replacement.
tr is short for “translate”. It is a member of the GNU coreutils package. Therefore, it's available in all Linux distros. The tr command reads a byte stream from standard input (stdin), translates or deletes characters, then writes the result to the standard output (stdout).
Using tr Command to Delete Characters You can use the -d (--delete) option followed by the character, set of characters or an interpreted sequence.
As far as I've learned, there isn't a drop in replacement for tr
, but this works simply and memorably for your use case:
echo $env:PATH.Replace(';',"`r`n")
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